#include <stdio.h> int main(int argc, char *argv[]) { unsigned short u16 = 0x1234; unsigned char *p_u16 = (unsigned char *)&u16; if(p_u16[0] == 0x34 && p_u16[1] == 0x12) printf("little endian!\n"); if(p_u16[0] == 0x12 && p_u16[1] == 0x34) printf("big endian!\n"); return 0; }