标签:
字节序分为 little-endian 和 big-endian,不同主机通信字节序转换过程:
- #include <arpa/inet.h>
int isBigEndian()
{
int flag = 0;
short a = htons(0x0102);
char* p = &a;
if(*p==0x01)
{
flag = 1;
}
return flag;
}
int isBigEndian()
{
int flag = 0;
short a = 0x0102;
char* p = &a;
if(*p==0x01)
{
flag = 1;
}
return flag;
}
标签:
原文地址:http://www.cnblogs.com/ZhangJinkun/p/4529557.html