判断PC机大小端
#include<stdio.h>
#include<stdlib.h> int main()
{
short a = 0x0102;
char *p = (char*)(&a); //低字节存储在低地址
if(*p == && *(p + ) == )
printf("小端\n"); //高字节存储在低地址
else if(*p == && *(p + ) == )
printf("大端\n"); return ;
}
判断PC机大小端
#include<stdio.h>
#include<stdlib.h> int main()
{
short a = 0x0102;
char *p = (char*)(&a); //低字节存储在低地址
if(*p == && *(p + ) == )
printf("小端\n"); //高字节存储在低地址
else if(*p == && *(p + ) == )
printf("大端\n"); return ;
}