Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.
More C++ Questions - How to retrieve a host or ip from an ip or host?
man socket.h
Also, for a very basic crash course in network programming check out http://en.wikibooks.org/wiki/Programming:C_Networking_in_UNIX
(But then again, you would probably be using c to do this ;))
The easiest way is to use
system("PING <IP/HOST> >> targetfile");
for example
system("PING www.google.com >> C:\\logfile.txt");
and then just read from the file since it will contain both the IP and the hostname.