Question related to serial library

I would like some help in overcoming a task. I want to send two identical int (16bits) variables with a qualifier byte (for example 'S' as a start byte then two identical int (16bits)). On the other side one arduino will look for an 'S' and then read two ints. Then compare the two received ints, if they are the same then clear the receiver buffer and do further processing.

Can someone please help me with some pointers as to how to start dealing with this. I came up with some transmit code, not sure if it is up to scratch.

char qual='S';
int firstWord=0B0000000011001100
int secondWord=0B0000000011001100

void setup(){
     Serial.begin(57600);

}

void loop(){
    Serial.print(qual);
    Serial.print(firstWord);
    Serial.print(secondWord);
    delay (50);
}

It's a bad idea to send like this. What happens if one number is for example 51, and the other one is 2512 ? You send S512512. How do you know where the second number start ?

Or, if both numbers are always the same, as in your example, why do you need to send both?

What are you trying to do exactly?

Have a look at the examples in Serial Input Basics - particularly the 3rd example. There is also a parse example.

...R

Thanks, I will go through that topic in detail, from just a quick browse it does seem very useful.

@guix - I want both int to be the same so as to confirm that data didn't got corrupted during transmission. If the two int differ when received, I want to discard that data.