strcpy(pszIpAddr, inet_ntoa(*(struct in_addr *)*host->h_addr_list) );求解释
strcpy(pszIpAddr, inet_ntoa(*(struct in_addr *)*host->h_addr_list) );
具体的,谢谢,主要是参数都是做什么的,看了百度百科有点迷糊了,尤其是这个‘->’的意思,以前没见过啊
[解决办法]
- C/C++ code
strcpy( pszIpAddr, inet_ntoa( * (struct in_addr *) * host->h_addr_list ));
[解决办法]
host->h_addr_list
*(host->h_addr_list)
(struct in_addr *)*(host->h_addr_list)
*(struct in_addr *)*(host->h_addr_list)
看清楚4个步骤, 然后看看结构体:
- C/C++ code
struct hostent { char *h_name; /* official name of host */ char **h_aliases; /* alias list */ int h_addrtype; /* host address type */ int h_length; /* length of address */ char **h_addr_list; /* list of addresses */ } #define h_addr h_addr_list[0] /* for backward compatibility */