Mega Code Archive

 
Categories / C / Development
 

Show byte order, example

#include <stdio.h> #include <sys/types.h> int main(void) { u_int32_t x = 0x12345678; /* 305419896 */ unsigned char *xp = (char *)&x; printf("Endian: "); printf("%0x %0x %0x %0x\n", xp[0], xp[1], xp[2], xp[3]); return 0; }