inet_pton在ipv4上没问题...但是用在ipv6上就出问题了...IP1:2a01:198:603:0:396e:4789:8e99:890fIP2:2a01:198:603:0::IP3:2a01::前两个IP转化出来的结果是一样一样的...第三个又不一样了...不知道问题出在哪...IP1,IP2结果都是0x9801012aIP3结果是0x12a了代码如下:#include#include#includeintmain(){structin_addrip;char*addr1,*addr2,*addr3;addr1=strdup("2a01:198:603:0:396e:4789:8e99:890f");addr2=strdup("2a01:198:603:0::");addr3=strdup("2a01::");inet_pton(AF_INET6,addr1,&ip);printf("0x%x\n",ip.s_addr);inet_pton(AF_INET6,addr2,&ip);printf("0x%x\n",ip.s_addr);inet_pton(AF_INET6,addr3,&ip);printf("0x%x\n",ip.s_addr);return1;}结果:0x9801012a0x9801012a0x12a
添加回答
举报
0/150
提交
取消