#include<iostream>
#include<cstring>
using namespace std;
void byteorder();
int main()
{
byteorder();
return 0;
}
void byteorder()
{
union{
short value;
char union_bytes[sizeof(short)];
}test;
test.value = 0x0102;//二进制为100000010
/*当小端取低字节8位二进制00000010转换就是2,再取一位就是1
同理大端就是1,2
*/
if((test.union_bytes[0]==1)&&test.union_bytes[1]==2)
cout <<"big endian"<<endl;
else if((test.union_bytes[0]==2)&&(test.union_bytes[1])==1)
cout <<"little endian"<<endl;
else
cout <<"unkonwn"<<endl;
}