   using bitset and outputting it correctly
#include <stdio.h>#include <stdlib.h>#include <fstream>#include <bitset>using namespace std;void main(){ofstream file ("ValuesAndFlags.txt",ios::out|ios::binary);bitset<1> flag;   char data;   for(int i = 0;i<128;i++) file<<data<<flag;   return; }I want to output 9 bits of data, but I'm getting 16 bits output instead, how can I get properly output 9 bits ?   
  Files store bytes. You can pack the information, but in the end you will have to pad the end to a multiple of 8 bits.   ;  Ya, ok i'll just need to make a conversion function to get bitset<8> to be a char and I'll be fine then.   