title: How to compare two ip address in c?
body: <p>I am trying to compare ip address and see if it fits in a range (i.e. network id and broadcast id)</p>
  
  <pre><code>starting =(rt_walker-&gt;dest).s_addr;
  subnet = (rt_walker-&gt;mask).s_addr;
  broadcast = starting | (~subnet);
  if(ip_address&gt;=starting &amp;&amp; ip_address&lt;=broadcast){
         found_route =1;
   }
  </code></pre>
  
  <p>This code works fine, but if i had "10.0.0.0" for rt_walker->dest then 
  this line (rt_walker->dest).s_addr is giving me 10 instead of a 32bit binary value. So, if was comparing "10.0.0.0"(starting address) with "9.90.100.78"(IP_address that is getting compared) it always falls in range(10 - 10.255.255.255) which should not be true.</p>