title: How to get IP address programmatically on Debian based system?
body: <p>I'm trying to retrieve the <code>IP Address</code> of the local machine in my program. The Operating System is <code>Ubuntu 8.10</code>. I tried using <code>gethostname()</code> and <code>gethostbyname()</code> to retrieve the <code>IP Address</code>. The answer I received is <code>127.0.1.1</code>. I learned that it seems to be a <code>Debian</code> thing:
  <a href="http://www.linuxquestions.org/questions/linux-networking-3/what-does-127.0.1.1-mean-623421/" rel="nofollow noreferrer">The document linked here explained the idea.</a><br></p>
  
  <p>The content of my <code>/etc/hosts</code> file is:<br></p>
  
  <blockquote>
    <p>127.0.0.1 localhost<br>
    127.0.1.1 mymachine</p>
  </blockquote>
  
  <p>In this case, is there any other way to programmatically (prefer C or C++) to get the IP Address without modifying the system file on the machine? </p>