Windows下获取本机IP地址方法介绍
if((hostinfo = gethostbyname(name)) != NULL)
{
#if 1
int i=;
printf("IP COUNT: %d\r\n",hostinfo->h_length);
for(i=;i<hostinfo->h_length;i++)
{
ip = inet_ntoa (*(struct in_addr *)hostinfo->h_addr_list[i]);
printf("IP #%d: %s\n", i+, ip);
} #else
int nCount = ;
while(hostinfo->h_addr_list[nCount])
{
ip = inet_ntoa (*(struct in_addr *)hostinfo->h_addr_list[nCount]); printf("IP #%d: %s\n", ++nCount, ip);
}
#endif
}
aa