int main(int argh,char ** argue){
union uni{
short s;
char c[2];
} un;
un.s = 0x0102;
std::cout << un.c[0] << "\t" << un.c[1] << std::endl;
if(un.c[0] == 1 && un.c[1] == 2){
std::cout << "大端字节序" << std::endl;
} else if (un.c[0] == 2 && un.c[1] == 1){
std::cout << "小端字节序" << std::endl;
}
}
共用体共用一块内存,short 占 8 位,最大存储为 0XFF (255), 0x0102 = 208会占两个字节