#include <iostream>
using namespace std;
int checkCPU()
{
union w
{
int a;
char b;
} c;
c.a = 1;
return c.b == 1;//如果低地址还是1说明低地址存放低字节,小端
}//如果低地址不是1,则高地址是1,说明低地址存放高字节,大端
int main()
{
if (checkCPU())
{
cout << "The endian of cpu is little \n";
}
else
{
cout << "The endian of cpu is big \n";
}
return 0;
}