bit manipulation - Can I input/output bits in C++ -
i figuring out how compress files , wondering if bit manipulation output file.
current have string of variable size n contains 0's , 1's. ex: 010111001010110
i want output file contains n bits instead of n characters.
also, if possible, how can read bits , convert string?
thank you.
update: if cannot write out bits directly , have pack bytes, mean can convert 8 bits char , output list of char? if so, happens if try store "00000000", means null?
you can't write bits out directly, have pack them @ least in eights. yes, means writing out bytes. note output padded bytes , have it.
to convert string containing 0s , 1s raw data, easiest way either use std::bitset
, if know length, or write loop advances eights, in
for (auto = 0; < str.size(); += 8)
Comments
Post a Comment