同时判断CPU是大端还是小端完全实现

高字节存储在高地址是小端,高字节存储在低地址是大端。
联合体union的存放顺序是所有成员都从低地址开始存放

int main()
{
    union _test
    {
       int a;
       short b;
    }test;
    test.a = 0x12345678;
    if(test.b == 0x1234)
      printf("big");
    if(test.b == 0x5678)
       printf("small");
}
原文地址:https://www.cnblogs.com/qianggezhishen/p/7349471.html