比如将十六进制数“2A12”拆成"2A"和"12",然
后再把"2A"和"12"对调位置合成"122A"
#include
main()
{
int a=0x2a12;
char b,c;
b=a>>8;
c=a&0x0ff;
printf("%x,%x",b,c);
a=(c<<8)|b;
printf("\n%x",a);
return 0;
}
unsigned short a = 0xA4F5;
unsigned char b = (a & 0xFF00)>>8;
unsigned char c = a & 0x00FF;
unsigned short d = (b<<8) | c;
可以用>> 和<<
运算符
你先给个例子,什么样的16位数据,什么样的8位数据?