Could some one tell me how to use gethostbyname() to convert the string entered by user into corresponding ip.If some one could show it by demonstrating a code that would be great.The user should get an option to enter the name of the site say google.com and the corresponding ip is shown and in case the user enters the ip it is converted in the site name.Thanks
Try this: Code: struct hostent *hp; hp=gethostbyname(addr); if(hp){ printf("%d.%d.%d.%d\n",hp->h_addr[0],hp->h_addr[1],hp->h_addr[2],hp->h_addr[3]); }