title: Calculate broadcast address from ip and subnet mask
body: <p>I want to calculate the broadcast address for:</p>
  
  <pre><code>IP:     192.168.3.1
  Subnet: 255.255.255.0
  =       192.168.3.255
  </code></pre>
  
  <p>in C.</p>
  
  <p>I know the way (doing fancy bitwise OR's between the inversed IP and subnet), but my problem is I come from the green fields of MacOSX Cocoa programing. </p>
  
  <p>I looked into the source of ipcal, but wasn't able to integrate it into my code base. There must be a simple ten lines of code somewhere on the internet, I just can't find it.
  Could someone point me to a short code example of how to do it in C?</p>