title: How do I implement a bit array?
body: <p>Current direction:</p>
  
  <p>Start with and unsigned char which is 1 Byte on my system using sizeof.  Range is 0-255.
  If length is the number of bits I need then elements is the number of elements (bytes) I need in my array.</p>
  
  <pre><code>constant unsigned int elements = length/8 + (length % y &gt; 0 ? 1 : 0);  
  unsigned char bit_arr[elements];
  </code></pre>
  
  <p>Now I add basic functionality such as set, unset, and test.  Where j is the bit per byte index, i is the byte index and h = bit index.  We have i = h / 8 and j = i % 8.  </p>
  
  <p>Psuedo-Code : </p>
  
  <pre><code>bit_arr[i] |= (1 &lt;&lt; j); // Set 
  bit_arr[i] &amp;= ~(1 &lt;&lt; j);  // Unset
  if( bit_arr[i] &amp; (1 &lt;&lt; j) ) // Test
  </code></pre>