#include #include #include #include #include using namespace std; int main() { string name = "amazon.com"; struct hostent* h = gethostbyname(name.c_str()); if (h) cout << h->h_name << '\n'; else herror("gethostbyname"); struct in_addr** addr_list = reinterpret_cast(h->h_addr_list); for (int i = 0; addr_list[i] != NULL; i++) cout << inet_ntoa(*addr_list[i]) << '\n'; return 0; }