查看内存管理是大端还是小端,使用union结构,union结构是里面的各个数据共用一个内存
//大小端查看
#include <iostream>
using namespace std;
union un{
short int s;
char c[sizeof(short int)];
};
int main(){
un test;
test.s=0x0102;
cout<<sizeof(short int)<<endl;
cout<<"c[0]="<<(int)test.c[0]<<endl;
cout<<"c[1]="<<(int)test.c[1]<<endl;
if(test.c[0]==1&&test.c[1]==2)cout<<"little "<<endl;
if(test.c[1]==1&&test.c[0]==2)cout<<"big"<<endl;
}