- 一次取得Integer裡的1Byte 範例:
int main()
{
int a = 0x01020304;
printf("[0]=%0x02x\n", ((char*)&a)[0]);
printf("[1]=%0x02x\n", ((char*)&a)[1]);
printf("[2]=%0x02x\n", ((char*)&a)[2]);
printf("[3]=%0x02x\n", ((char*)&a)[3]);
}
{
int a = 0x01020304;
printf("[0]=%0x02x\n", ((char*)&a)[0]);
printf("[1]=%0x02x\n", ((char*)&a)[1]);
printf("[2]=%0x02x\n", ((char*)&a)[2]);
printf("[3]=%0x02x\n", ((char*)&a)[3]);
}
執行結果:
[0]=0x04
[1]=0x03
[1]=0x02
[1]=0x01
[1]=0x03
[1]=0x02
[1]=0x01
沒有留言:
張貼留言