#include <stdio.h>
union SHORT_UN{
unsigned charBYTE;
short unsigned int value;
};
int main()
{
unionSHORT_UN short_int;
unsigned char temp;
short_int.value = 0x1234;
printf("交换之前0x%x\n", short_int.value);
temp = short_int.BYTE;
short_int.BYTE=short_int.BYTE;
short_int.BYTE= temp;
printf("交换之后0x%x\n", short_int.value);
return 0;
}
只需要简单交互就可以了。效率比较高。在VC++6.0上编译通过。
页:
1
[2]