题目:你的电脑存储方式是大端存储还是小端存储
<span style="font-family:Microsoft YaHei;font-size:18px;">//判断大小端
#include <stdio.h>
#include<stdlib.h>
int main()
{
//union w
//{
// int a; //4 bytes
// char b; //1 byte
//} c;
//c.a = 1;
//if (c.b == 1)
// printf("It is Little_endian!\n");
//else
// printf("It is Big_endian!\n");
//system("pause");
int a = 0x01;
char * p = (char*)& a;
if (*p == 1)
{
printf("little endian\n");
}
else
{
printf("big endian\n");
}
system("pause");
return 0;
}</span>
正如上图所示,小端模式下的存储方式:高地址存放高位数据,低地址存放低位数据