标签:
判断PC机大小端
1 #include<stdio.h> 2 #include<stdlib.h> 3 4 int main() 5 { 6 short a = 0x0102; 7 char *p = (char*)(&a); 8 9 //低字节存储在低地址 10 if(*p == 2 && *(p + 1) == 1) 11 printf("小端\n"); 12 13 //高字节存储在低地址 14 else if(*p == 1 && *(p + 1) == 2) 15 printf("大端\n"); 16 17 return 0; 18 }
标签:
原文地址:http://www.cnblogs.com/cpsmile/p/4422540.html