1. 简述字节序的概念,并用指针方式,或者共用体(联合体)的方式计算本机是大端还是小端(上交)
#include<myhead.h>
typedef union
{
unsigned int a;
unsigned char b;
}zixu;
int main(int argc, const char *argv[])
{
zixu num;
num.a=0x12345678;
if(num.b==0x78)
{
printf("这是小端存储\n");
}
else if(num.b!=0x78)
{
printf("这是大端存储\n");
}
num.b=num.a;
int s=0x12345678;
char *p=(char*)&s;
printf("%#x\n",*p);
return 0;
}