/* Convert a fully qualified domain name into its IP address(es). */ #include #include #include int main(int argc, char **argv) { struct hostent *entry = gethostbyname("indira.uu.nl"); char **pp; if (entry == NULL) { fprintf(stderr, "%s: h_errno == %d\n", argv[0], h_errno); return EXIT_FAILURE; } for (pp = entry->h_addr_list; *pp != NULL; ++pp) { char buffer[INET6_ADDRSTRLEN]; inet_ntop(entry->h_addrtype, *pp, buffer, sizeof buffer); printf("%s\n", buffer); } return EXIT_SUCCESS; }