//短整型正好两个字节
#include
#define uchar unsigned char
#define ushort unsigned short
ushort x=0x0102;
//即 258
uchar *p;
uchar x_low,x_high,temp;
void main()
{
p=(uchar*)(&x);
x_low=*p;
x_high=*(++p);
printf("%u,%u\n",x_low,x_high); //指针实现短整型的高字节
和低字节分离
*p=x_low;
--p;
*p=x_high;
printf("%u\n",x);// 指针实现短整型的高字节和低字节位
置交换
}
结果:1
2
513