XORING first 3 bytes of data in 4byte frame received from serial port

Hello every body...........
I am new to this forum. I want to receive 4 bytes of data through serial port of arduino mega adk. and want XOR the first three bytes if their XOR data is equal to the last 4th byte then want to send it to one of analog output ports. But I dont know how define 4byte frame and then extract first three bytes.
Plz help me in this regard......

But I dont know how define 4byte frame

byte frame[4];

and then extract first three bytes.

Why do you need to "extract" them? Referencing the bytes by index (0, 1, or 2) should be sufficient.

because when the XORed data is equal to the last 4th byte then it means that data is correct not garbage......then it should be sent to analog port otherwise not.

if (frame[0]^frame[1]^frame[2] == frame[3])

There is no reason to "extract" the data from the array. XOR the first three elements of array (in positions 0, 1, and 2) and compare the result to the 4th (in position 3).

But frame[0] is extracting a byte from the array!

But frame[0] is extracting a byte from the array!

Like a dentist extracts a tooth? Not in my mind.

Extracting information is not like extracting an object - you take a copy (unless you meant quantum information)

Maybe with a queue or list you would expect extracting to have side-effects, but not a static
array.