#include <stdio.h>
#include <netdb.h>
 
int main (int argc, char *argv[])
{
   struct hostent *host ;
   struct in_addr address ;
   int i ;
 
   if (argc != 2)
   {
      fprintf (stderr,"Uso: resolver nome ");
      exit (1);
   }
 
   if ( ! inet_aton (argv[1], &address) )
   {
      perror ("inet_aton") ;
      exit (1) ;
   }
 
   host = gethostbyaddr (&address, sizeof (address), AF_INET) ;
   if ( ! host )
   {
      herror ("gethostbyaddr");
      exit (1);
   }
 
   printf ("Nome principal: %s\n", host->h_name) ;
 
   printf ("Outros nomes  :\n") ;
   for (i=0; host->h_aliases[i]; i++)
      printf ("  %s\n", host->h_aliases[i]) ;
}