How do you find, if a machine is big endian or little endian?
int x = 0xdeadbeef;
char *c = (char *)&x;
if(*c == 0xde)
printf("Big-endian\n");
else if(*c == 0xef)
printf("little-endian\n");
else
printf("memory corrupt ?\n");
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment