14 lines
308 B
C
14 lines
308 B
C
|
#include <stdio.h>
|
||
|
#include <arpa/inet.h>
|
||
|
|
||
|
int main(int argc, char const *argv[])
|
||
|
{
|
||
|
unsigned int data=0x01020304;
|
||
|
// 转成网络端数据(小端转大端)
|
||
|
u_int32_t data2 = htonl(data);
|
||
|
printf("主机字节序: %#x\n",data);
|
||
|
printf("网络字节序: %#x\n",data2);
|
||
|
|
||
|
return 0;
|
||
|
}
|