// Programa resolv-ip.c #include #include extern int errno; int main() { unsigned char bytesIP[4]; /* alocacao de 4 bytes para endereco IP */ struct hostent * hostentp; printf("Entre com o endeco IP do host: "); scanf("%d.%d.%d.%d", &bytesIP[0],&bytesIP[1],&bytesIP[2],&bytesIP[3]); printf("Endereco IP: %u.%u.%u.%u \n", bytesIP[0], bytesIP[1], bytesIP[2], bytesIP[3]); hostentp = gethostbyaddr(bytesIP,4,AF_INET); if (hostentp == NULL) /* Erro */ perror("Erro na chamada gethostbyname()"); else /* ok */ { printf("Nome = %s \n", hostentp->h_name); } }