大端存储模式:数据的地位保存在内存的高位,数据的高位保存在内存的低位。
小端存储模式:数据的高位保存在内存的低位,数据的低位保存在内存的高位。
有两种判断大小端的方式:
#include<stdio.h>
#include<stdlib.h>
int check_sys2()
{
union
{
int i;
char j;
}un;
un.i = 1;
return un.j;
}
int check_sys1()
{
int i = 1;
return (*(char*)&i);
}
int main()
{
int ret = check_sys2();
if (ret == 1)
{
printf("这是小端!!!\n");
}
else
printf("这是大端!!!\n");
system("pause");
return 0;
}