From mboxrd@z Thu Jan 1 00:00:00 1970 From: HIToC Subject: Host IP address Date: Tue, 22 Feb 2005 17:53:46 +0100 Message-ID: <200502221751.44585.hitoc_mail@yahoo.it> Mime-Version: 1.0 Content-Transfer-Encoding: 8BIT Sender: linux-c-programming-owner@vger.kernel.org List-Id: Content-Type: text/plain; charset="us-ascii" To: linux-c-programming@vger.kernel.org Hello all! Sometimes is useful to know the IP address of the machine we are working on, for example when we connect a SMTP server and do the EHLO command. I have written a short C++ program that first prints the host name and the host IP address, then if arguments from command line are passed prints the IP address of each domain name. /* IPadress.cpp Author: HIToC */ #include #include #include #include #include #include #include #include int main(int argc, char* argv[]) { hostent *hh; string IP, my_name; char* host_name = new char[64]; gethostname(host_name, 64); my_name = host_name; cout <<"Host name:\t\t" <h_addr)); cout <<"My IP address:\t\t" <h_addr)); cout <<"IP address of " <