#include
int main()
{
int a=0x9867, low, high;
high = (a>>8)&0x00ff; //98在高字节
low = (a<<8)&0xff00; //67低字节
printf("%x--%x\n", high, low); //结果输出应为:98--6700
int bb, alow=0x23, ahigh=0x56;
bb=ahigh;
bb=(ahigh<<8) | alow;//直接赋值的话ahigh默认存在低字节所以要左移,然后与运算
printf("b=%x\n", bb); //结果输出应为:b=5623
return 0;
}
阅读(2175) | 评论(1) | 转发(0) |