Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

DOMAIN NAME SYSTEM in C

#include<stdio.h>
#include<stdlib.h>
#include<errno.h>
#include<netdb.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>int main(int argc,char *argv[1])
{
struct hostent *hen;if(argc!=2)
{
fprintf(stderr,"Enter the hostname \n");exit(1);
}
hen=gethostbyname(argv[1]);
if(hen==NULL){fprintf(stderr,"Host not found \n");
} 
printf("Hostname is %s \n",hen->h_name); 
printf("IP address is %s \n",inet_ntoa(*((struct in_addr *)hen->h_addr)));
}


Input: ./a.out www.google.com
Output:
Host name is www.google.com
IP Address is 173.194.73.99