#include<stdio.h>
struct w{
char low;
char high;
};
union u{
struct w byte;
short word;
}uw;
main( ){
int result;
uw.word=0x1234;
printf("word value:%04x\n",uw.word); //1234
printf("high byte:%02x\n",uw.byte.high); //12
printf("low byte:%02x\n",uw.byte.low); //34
uw.byte.low=0x74;
printf("word value:%04x\n",uw.word); //1274
result=uw.word+0x2a34;
printf("the result:%04x\n",result); //3ca8
}
高低位
最新推荐文章于 2024-01-07 15:57:10 发布