判断大小端
代码
#include <myhead.h>
typedef union
{
unsigned int a;
unsigned char b;
}data;
int main(int argc, const char *argv[])
{
data c = {0x12345678};
if(c.b == 0x12)
{
printf("大端!\n");
}
else if(c.b == 0x78)
{
printf("小端\n");
}
return 0;
}
结果
思维导图