Writing binary data to a file (bits).
I'm under the assumption that the smallest amount of data you can write to a file is a byte - 4 bits. I have a problem, working with a compressed file, that I need to solve.
I have the algorithm and everything, but I'm stuck on two parts, which I could not find supporting information for. I need to be able to read 3 bits from a file and then from that number, determine how many bits to write out - from 1-6.
How can I possibly write out a variable amount of bits? I figure that if I need to read 3 bits from a file, I can just read in a char (4 bits), take those 4 bits, and do bit operations on them to single what it would be if it were just a 3 bit object.
Does anybody have any ideas/suggestions? Thanks.
p.s. I'm not writing any code at the moment, I'm just trying to get the design details down.