64,677
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
static union
{
char c[4];
unsigned char l;//c[4]和l共有一个四字节的内存空间
} endian_test={ {'l','?','?','b'} };
#define ENDIANNESS ( (char)endian_test.l )
int main()
{
if (ENDIANNESS == 'l')//低地址存低字节就是little endian
printf("little endian\n");
else
printf("big endian\n");
}
if (ENDIANNESS == 'l')
//little endian
else
//big endian