title: Can I input/output bits in C++
body: <p>I am figuring out how to compress files and I was wondering if I could do bit manipulation with an output file.</p>
  
  <p>Current I have a string of variable size n that contains only 0's and 1's. 
  ex: 010111001010110</p>
  
  <p>I want to output a file that contains only n bits instead of n characters.</p>
  
  <p>Also, if that is possible, how can I read those bits back and convert it back into a string?</p>
  
  <p>Thank you.</p>
  
  <p>Update: If I cannot write out bits directly and have to pack it into bytes, does that mean I can convert the 8 bits into a char and just output a list of char? If so, what happens if I try to store "00000000", which means null?</p>