怎样判断机器的字节顺序是高字节在前还是低字节在前 ??
- #include <stdio.h>
-
-
int main(int argc, char *argv[])
-
{
-
int x = 1;
-
if(*(char *)&x == 1)
-
printf("little-endian\n");
-
else
-
printf("bit-endian\n");
-
-
return 0;
-
}
- ywx@yuweixian:~/yu/c/test$ ./test
-
little-endian
阅读(986) | 评论(0) | 转发(0) |