Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
17 lines (15 sloc) 314 Bytes
#include <stdio.h>
int main(int argc, char **argv)
{
union {
unsigned short s;
unsigned char c[sizeof(unsigned short)];
} u;
u.s = 0x0102;
if (u.c[0] == 0x02 && u.c[1] == 0x01) {
printf("little-endian\n");
} else {
printf("big-endian\n");
}
return 0;
}