I'm trying to verify the contents of an unsigned short variable in C, and printf is giving me unexpected output (this is on an Intel so it's little-endian):
unsigned short us = 52275; // binary 1100 1100 0011 0011
printf("%x\n", *(char *)&us); // gives me 33, as expected
printf("%x\n", *((char *)&us + 1)); // gives me ffffffcc
I would expect the second printf to produce cc, since the char * is incremented by 1 and then dereferenced. Can anyone explain why I get what looks like an int instead of a char?