title: Reading individual bits from Memory
body: <p>To convert a number from base 10 to base 2, I thought of directly reading bits from memory instead of performing bitshift (<code>&gt;&gt;</code>).</p>
  
  <p>Consider the program:</p>
  
  <pre><code>int n = 14;
  bool* pointer = (bool*)&amp;n;
  for(int i = 0; i &lt; 32; i++)
      cout &lt;&lt; *(p + i);
  </code></pre>
  
  <p>The program is not giving the correct output.</p>
  
  <p>The program below works:</p>
  
  <pre><code>int n = 14;
  bool *p = (bool*)&amp;n;
  for(int i = 0; i &lt; 32; i++){
      cout &lt;&lt; *p;
      n = n &gt;&gt; 1;
  }
  </code></pre>
  
  <p>Bitshifting wastes unnecessary time. Also please point out the error in the first code snippet.</p>