title: Display each bit in a char C++
body: <p>I want to display each bit in a char. This however does not work :</p>
  
  <pre><code>    char flags = byteFromFile();
      for( int i = 0; i &lt; 8; i++ ){
          int tmp = ( flags &gt;&gt; i ) &amp; 0x2;
          cout &lt;&lt; tmp;
      }
      cout &lt;&lt; endl;
  </code></pre>
  
  <p>What's wrong with this code? </p>
  
  <p>I get only zeros but the byte has a value of 3 ( I looked it up with a debugger ).</p>