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 }
时间: 2024-10-21 05:37:17