C Program to Display Hostname And IP Address

| Last Updated: | In: C Programming Tutorial


In this program, we will share how to get the Hostname and IP address of a local machine. In this program, I am using these predefined functions: 1) gethostname(): Get the hostname of a local machine. 2) gethostbyname(): Get the host information corresponding to the hostname. 3) inet_ntoa(): This function will convert an (Ipv4) Internet …