大端小端判断程序
#include <stdio.h>
void byteOrder()
{
union
{
short value;
char union_bytes[sizeof(short)];
} test;
test.value = 0x0102;
if (test.union_bytes[0] == 1 && test.union_bytes[1] == 2)
printf("big endian \n");
else if (test.union_bytes[0] == 2 && test.union_bytes[1] == 1)
printf("little endian \n");
else
printf("unknown... \n");
}
int main()
{
byteOrder();
return 0;
}
博客主要围绕大端小端判断程序展开,涉及信息技术领域中关于字节序判断的内容。
2700

被折叠的 条评论
为什么被折叠?



