Click to See Complete Forum and Search --> : how to convert hostent member h_addr to a string?


lab1
March 13th, 2009, 02:41 PM
Hello,

I have a hostent h_addr and I want to convert that to a string IP address. How can I do that?

I tried this:


string ipaddress;
struct hostent *h;
h = gethostbyname(hostname.c_str());
ipaddress=h->h_addr;

but that doesnt work..

Thanks!

Richard.J
March 14th, 2009, 07:31 AM
lookup inet_ntoa or inet_ntop