Hi,
Go through the file char by char, looping through the bits in the char and push_back()ing them into your vector<bool>. To get a particular bit out of the char, you:
create a char with a true bit in only that place, eg 00000010 for place 1, or 00100000 for place 5, and
use the bitwise & operator to compare that to your original char, eg
00100000 & 01001010
The result will not have any true bits in it, unless both chars have a bit in that place, and if the answer has any true bits in it, it will be true when you cast it to bool.
To get a char with only a bit in a particular place, you do:
1 << place
to slide 1 into the right place. You will actually get an int, but it will work fine.
So:
-
for (int place = 0; place < 8; place++)
-
myVector.push_back(myChar & (1 << place));
-
Hope this helps.