#include <stdio.h>
union test
{
int a;
char b;
};
int main()
{
union test t;
t.a = 0x12345678;//如果是小端 在内存中从低地址到高地址依次存放 78 56 34 12
//如果是大端 在内存中从低地址到高地址依次存放 12 34 56 78
printf("%x\n",t.b);//如果是小端 打印78
//如果是大端 打印12
return 0;
}
判断大小端
最新推荐文章于 2020-11-30 20:33:35 发布