호스트 IP 주소 얻기
-인자로 전달한 문자열 포인터에 호스트 IP 주소를 저장한다. #include #include void GetHostIP(char* ip){ WORD wVersionRequested; WSADATA wsaData; char name[255]; PHOSTENT hostinfo; wVersionRequested = MAKEWORD(2,0); if(WSAStartup(wVersionRequested,&wsaData) == 0){ if(gethostname(name,sizeof(name)) ==0){ if((hostinfo = gethostbyname(name)) != NULL){ strcpy(ip,inet_ntoa(*(struct in_addr*)*hostinfo->h_addr_list)); } } } WSACleanup(); }