*** 自写代码:判断CPU是Big Endian还是Little Endian

#include <iostream>
#include <string.h>
using namespace std;
bool checkLittleEnd (void)
{
    union test
    {
        int a;
        char b;
    } t;
    t.a = 1;
    return (t.b==1);
}
int main()
{
    if (checkLittleEnd())
        cout << "Little End!" << endl;
    else
        cout << "Big End!" << endl;
    return 0;
}
原文地址:https://www.cnblogs.com/superrunner/p/10165164.html