Hello,
How can I retrieve the IPv4 address numbers-and-dots notation of a host?
For some reason, this example always prints 0.0.0.0. What am I missing?
Thanks in advance.
Code:char* host="some host URL" ... if(!(hostInfo = gethostbyname(host))){ herror("error: gethostbyname"); exit(-1); } addrSrvr.sin_addr.s_addr = inet_aton(hostInfo->h_addr, &addrSrvr.sin_addr); printf("IP address: %s\n", inet_ntoa(addrSrvr.sin_addr));