void test()
{
char a,b,c,d;
int x=0x30313233;
cout << *((char*)&x) << endl;
x0 = ((char*)&x)[0];
x1 = ((char*)&x)[1];
x2 = ((char*)&x)[2];
x3 = ((char*)&x)[3];
cout << "x0=" << x0 << endl;
cout << "x1=" << x1 << endl;
cout << "x2=" << x2 << endl;
cout << "x3=" << x3 << endl;
/*
对于小端序,输出
x0=3
x1=2
x2=1
x3=0 //0x30对应到十进制的48,也即是ascii的'0',作为char类型输出显示为0
*/
}
网友评论