title: How to put bit sequence into bytes (C/C++)
body: <p>I have a couple of integers, for example (in binary represetation):</p>
  
  <p>00001000, 01111111, 10000000, 00000001</p>
  
  <p>and I need to put them in sequence to array of bytes(chars), without the leading zeros, like so:</p>
  
  <p>10001111 11110000 0001000</p>
  
  <p>I understand that it is must be done by bit shifting with &lt;&lt;,>> and using binary or |. But I can't find the correct algorithm, can you suggest the best approach?</p>
  
  <p>The integers I need to put there are unsigned long long ints, so the length of one can be anywhere from 1 bit to 8 bytes (64 bits).</p>