int big_endian();
int little_endian();
int _tmain(int argc, _TCHAR* argv[])
{
int iBigEndian = big_endian();
int iLittleEndian = little_endian();
return 0;
}
int big_endian()
{
union
{
long l;
char c[sizeof(long)];
}u;
u.l = 1;
return u.c[sizeof(long) - 1] == 1;
}
int little_endian()
{
union
{
long l;
char c;
}u;
u.l = 1;
return u.c == 1;
}