http://blog.csdn.net/ce123_zhouwei/article/details/6971544
一个小程序判断机器的大小端
-
#include <stdio.h>
-
-
int main(void)
-
{
-
union {
-
int s;
-
char c[sizeof(int)];
-
}un;
-
un.s = 0x12345678;
-
-
printf("%p,%p,%p,%p\n",un.c[0],un.c[1],un.c[2],un.c[3]);
-
printf("%p,%p,%p,%p\n",&un.c[0],&un.c[1],&un.c[2],&un.c[3]);
-
# if __BYTE_ORDER == __LITTLE_ENDIAN
-
printf("little endian\n");
-
# elif __BYTE_ORDER == __BIG_ENDIAN
-
printf("big endian\n");
-
# else
-
# error "__BYTE_ORDER neither __LITTLE_ENDIAN nor __BIG_ENDIAN!!!"
-
# endif
-
return 0;
-
}
阅读(942) | 评论(0) | 转发(0) |