测试代码:
short a = 0x0102;
if( *( (char * ) &a ) == 0x02 )
cout<<"小端法"<<endl;
else if( *( (char * ) &a ) == 0x01 )
cout<<"大端法"<<endl;
else
cout<<"Unknown"<<endl;
cout<<a<<endl;
short a = 0x0102;
if( *( (char * ) &a ) == 0x02 )
cout<<"小端法"<<endl;
else if( *( (char * ) &a ) == 0x01 )
cout<<"大端法"<<endl;
else
cout<<"Unknown"<<endl;
cout<<a<<endl;