Hi,
I am handling bits with the STL bitset class. My code sets up an array of 8-bit bitsets, the byte data coming from a file.
The following is the code I am using....now, how can I get the contents of my array of 8-bit bitsets into an array of boolean since the content is either 0 or 1?
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <bitset>
#include <fstream>
using namespace std;
typedef vector<bitset<8> > bitarray;
void Dummy()
{
bitarray::iterator numbits;
unsigned long ul;
// Read binary file back into a new bitset array
bitarray inbits;
ifstream fp("C:\\test.bin",ios_base::binary);
while(fp.good())
{
ul = fp.get();
if (fp.good())
inbits.push_back(bitset<8>(ul));
}
// Print out bitset array again as char 0,1
for (numbits = inbits.begin(); numbits!=inbits.end (); numbits++)
{
cout << *numbits << endl;
}
}
I am handling bits with the STL bitset class. My code sets up an array of 8-bit bitsets, the byte data coming from a file.
The following is the code I am using....now, how can I get the contents of my array of 8-bit bitsets into an array of boolean since the content is either 0 or 1?
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <bitset>
#include <fstream>
using namespace std;
typedef vector<bitset<8> > bitarray;
void Dummy()
{
bitarray::iterator numbits;
unsigned long ul;
// Read binary file back into a new bitset array
bitarray inbits;
ifstream fp("C:\\test.bin",ios_base::binary);
while(fp.good())
{
ul = fp.get();
if (fp.good())
inbits.push_back(bitset<8>(ul));
}
// Print out bitset array again as char 0,1
for (numbits = inbits.begin(); numbits!=inbits.end (); numbits++)
{
cout << *numbits << endl;
}
}