unsigned int convert_order32(unsigned int before)
{
  int i = 0;
  unsigned int r = 0;

  for (i = 0; i < 32; ++i)
  {
    if (before&1<<i)
    {
      r=r|1<<(i/4%2?(7-(i/4-1))*4+i%4:(7-(i/4+1))*4+i%4);
    }
  }

  return r;
}

int main(int argc,char *argv[])
{
  int i = 0;
  struct hostent *host_entry;
  struct in_addr in_addr;
  host_entry = gethostbyname(argv[1]);

  while (host_entry->h_addr_list[i] != NULL)
  {
    in_addr.s_addr = *((u_long *)(host_entry->h_addr_list[i]));
    printf("official host name: \t\t\t%s\n",host_entry->h_name);
    printf("host address type: \t\t\t%d\n",host_entry->h_addrtype);
    printf("length of host address : \t\t%d\n",host_entry->h_length);
    printf("IP address: \t\t%s (hexa) 0x%x\n",
        inet_ntoa(in_addr),
        convert_order32(in_addr.s_addr));
    ++i;
  }

  return 0;
}

참고로 이건 학부 네트워크 수업 시간 때 만든 건데 convert_order32()는 당시 한창 코드 골프를 하고 있던 때라 바이트 정렬을 30분 정도 고민해서 만든 것이다. -_-

official host name: 			www.g.daum.net
host address type: 			2
length of host address : 		4
IP address: 		180.70.93.55 (hexa) 0xb4465d37

official host name: 			www.g.daum.net
host address type: 			2
length of host address : 		4
IP address: 		180.70.93.56 (hexa) 0xb4465d38
Retrieved from http://hyacinth.byus.net/moniwiki/wiki.php/C/gethostbyname
last modified 2015-04-17 00:18:39