#include<stdio.h> #include<cstdlib> int main() { union { short s; char c[sizeof(s)]; }un; un.s = 0x0102; if (sizeof(short) == 2) { if (un.c[0] == 1 && un.c[1] == 2) { printf("big-endina "); } else if (un.c[1] == 1 && un.c[0] == 2) { printf("small-endina "); } else { printf("unknown "); } } else { printf("sizeof(short) = %d ", sizeof(short)); } return 0; }