#include <stdio.h> #include <Winsock2.h> int main(int argc, char *argv[]) { WSADATA wsaData; char name[255]; PHOSTENT hostinfo; WORD wVersionRequested = MAKEWORD( 2, 0 ); char *ip; if( WSAStartup( wVersionRequested, &wsaData ) == 0 ) { if( gethostname( name, sizeof(name)) == 0) { printf("Host Name : %s\n", name); if((hostinfo = gethostbyname(name)) != NULL) { int nCount = 0; while(hostinfo->h_addr_list[nCount]) { ip = inet_ntoa(*(struct in_addr *)hostinfo->h_addr_list[nCount]); printf("Host IP (%d): %s\n", ++nCount, ip); } } } } return 0; }