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?


devilsson2010's Avatar
Member
0 0

Does anyone know how to retrieve a host from an ip in C++. Also, I need to know how to retrieve an ip from a host.


Uber0n's Avatar
Member
0 0

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.


spyware's Avatar
Banned
0 0

Uber0n wrote: Crap

Sorry, but, teaching bad habits is… bad.


ghost's Avatar
0 0

spyware wrote: [quote]Uber0n wrote: Crap

Sorry, but, teaching bad habits is… bad.[/quote]

+1 using built in shell functions in a c program is full of absolute fail. They write headers for a reason.