Try this:

Code:
  struct hostent *hp;

  hp=gethostbyname(addr);
  if(hp){
    printf("%d.%d.%d.%d\n",hp->h_addr[0],hp->h_addr[1],hp->h_addr[2],hp->h_addr[3]);
  }