gethostname的使用问题
CString GetLocalIp(){ struct hostent* phost; char ip[20]; char hostname[50]; gethostname(hostname,50); phost = gethostbyname(hostname); char ** names; names = phost->h_aliases; char ** iplist; iplist = phost->h_addr_list; while( * iplist) { strcpy(ip,inet_ntoa( * (struct in_addr * ) * iplist)); iplist ++; } CString LocalIp = ip; return LocalIp;}