qfedu-network-advanced-level/day2/n2.c

14 lines
308 B
C
Raw Normal View History

2023-09-05 20:54:17 +08:00
#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;
}