title: Printing binary char in c
body: <p>I cannot, for the love of myself figure out what the logic is behind this C code.</p>
  
  <p>Supposedly, the following should print out the binary representation of an unsigned char x, and we are only allowed to fill in the blanks.</p>
  
  <pre><code>void print_binary(unsigned char x) {
      int b = 128;
  
      while (__________________) {
  
          if (b &lt;= x) {
              x -= b;
              printf("1");
          } else
              printf("0");
  
          ______________________;
      }
  }
  </code></pre>
  
  <p>Of course I could game the program by simply ignoring the lines above. However I'm under the impression that this is not really the way to do things (it's more of a hack).</p>
  
  <p>I mean really now, the first condition checks whether 128 is &lt;= the char, but isn't an unsigned char, what, 255 bytes? So why is it only printing '1' in it.</p>
  
  <p>Perhaps I'm missing something quite obvious (not really a c programmer) but the logic just doesn't sink into me this time.</p>
  
  <p>Can anyone point me in the right direction? And if you can give me a clue without completely saying the answer, that would be heavenly.</p>