1
int main()
{   
    unsigned short crc = 0x00;
    unsigned char buffer[4] = {0x01,0x02,0x72,0xAE};
    memcpy((void *)&crc, (void *)&buffer[2],2);
    printf("crc = 0x%x \n",crc);

    return 0;
}

for above program i was expecting crc value to be : 0x72AE but it comes out to be: crc = 0xAE72

I am not able to understand why the bytes are shuffled, even though i am doing a memcpy?

Any kind of help will be appreciated. Thanks in advance.

Jack
  • 694
  • 8
  • 20

0 Answers0