Find out endianess in C

i386 is little-endian.
m68k is big-endian (most significant byte comes first)

int is_big_endian(void) { union { uint32_t i; uint8_t c[4]; } e = { 0x01000000 }; return e.c[0]; } int main(void) { printf("System is %s-endian.\n", is_big_endian()?"big":"little"); return 0; }