#include <stdio.h> #include <stdlib.h> int main(void) { short int a = 0x1234; char *p = (char *)&a; printf("p=%#hhx\n", *p); if (*p == 0x34) { printf("little endian\n"); } else if (*p == 0x12) { printf("big endia\n"); } else { printf("unknown endia\n"); } return 0; } |
#define sw16(x) \ ((short)( \ (((short)(x) & (short)0x00ffU) << 8 ) | \ (((short)(x) & (short)0xff00U) >> 8 ) )) |
歡迎光臨 (http://www.zg4o1577.cn/bbs/) | Powered by Discuz! X3.1 |