title: Bytes to Binary in C
body: <p>I'm trying to simply convert a byte received from fget into binary.</p>
  
  <p>I know the value of the first byte was 49 based on printing the value. I now need to convert this into its binary value.</p>
  
  <pre><code>unsigned char byte = 49;// Read from file
  unsigned char mask = 1; // Bit mask
  unsigned char bits[8];
  
    // Extract the bits
  for (int i = 0; i &lt; 8; i++) {
      // Mask each bit in the byte and store it
      bits[i] = byte &amp; (mask &lt;&lt; i);
  }
   // For debug purposes, lets print the received data
  for (int i = 0; i &lt; 8; i++) {
  printf("Bit: %d\n",bits[i]);
  }
  </code></pre>
  
  <p>This will print:</p>
  
  <pre><code>Bit: 1
  Bit: 0
  Bit: 0
  Bit: 0
  Bit: 16
  Bit: 32
  Bit: 0
  Bit: 0
  Press any key to continue . . .
  </code></pre>
  
  <p>Clearly, this is not a binary value. Any help?</p>