- 大端模式,是指数据的高字节保存在内存的低地址中,而数据的低字节保存在内存的高地址中。
- 小端模式,是指数据的高字节保存在内存的高地址中,而数据的低字节保存在内存的低地址中。
#include<stdio.h>
int main()
{
int a = 1;
// H L
//小端 00 00 00 01.
//大端 01 00 00 00
if (((char*)&a)[3] == 1)//把a地址强转成char指针,以字节来访问a的第四位
printf("big");
else
printf("small");
return 0;
}