检查你的机器是大端格式还是小端格式的C程序
#include <stdio.h>
union check
{
int high;
char low;
} test_ok;
int main(int argc,char *argv[])
{
short test=0x0110;
char *p=(char *)&test;
if(p[0]==0x10)
{
//sm format
printf("This arch is small format bits\n");
}
else
{
//big format
printf("This arch is big format bits\n");
}
printf("point address1=0x%.4x address2=0x%.4x\n",p[0],p[1]);
test_ok.high=1;
if(test_ok.low==1)
{
printf("Arch is small format\n");
}
else
{
printf("Arch is big format\n");
}
return 0;
}