1. Verify that sizeof(struct A) is indeed 4
2. Verify that this gives you the same result.
Code:
struct A H;
u_char *p; // points to a sequence of bytes 12 34 08 00
memcpy(&H,p,sizeof(H));
if (H.Short3 == Match)
If p is a mis-aligned address, then dereferencing members with alignment requirements can produce weird effects.
3. Verify the endian of your machine.
Code:
struct A H;
H.Char1 = 0x12;
H.Char2 = 0x34;
H.Short3 = Match;
unsigned char *p = (unsigned char *)&H;
for ( i = 0 ; i < 4 ; i++ ) printf("%02x ", p[i]);
If your machine is opposite endian to your data stream, then you'll see
12 34 00 08