目录
判断大小端
- 一般方法
bool IsSmallEndian()
{
int num = 1;
char *p = (char *)#
if (*p == 1) {
printf("小端\n");
return true;
}
return false;
}
- union
bool IsSmallEndian()
{
union Un {
char c;
int i;
} u;
u.i = 1;
if (u.c == 1) {
printf("小端\n");
return false;
}
printf("大端\n");
return true;
}
标签:小端,return,C++,更新,char,int,接口,printf,false
From: https://www.cnblogs.com/kongweisi/p/17384415.html