get host name in C
A program to get hostname in C Following is an example C program to read the hostname from C. #include<stdio.h> #include<string.h> #include<stdlib.h> #include<sys/socket.h> #include<errno.h> #include<netdb.h> #include<arpa/inet.h> int hostname_to_ip(char * , char *); int main(int argc , char *argv[]) { if(argc <2) { printf(“Please provide a hostname to resolve”); exit(1); } char *hostname = argv[1]; char …