Sign in to follow this  
vaneger

using bitset and outputting it correctly

Recommended Posts

#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 ?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this