I am working on a compressor which compresses text files using Huffman coding in C++. After I perform the encoding, I get a bitstring(assume arbitrary length or say length = 2611) which represents the encoded file. Now, I want to write this bitstring to a binary file. How can I do this? Can bitset be of some use?
I am aware of the fact that the file size has to be integer number of bytes, so I will pad the bitstring to make the length a multiple of 8.
I saw some other related questions but they used pre-determined size bitset. In my case the bitstring can be quite long.
Thanks in advance!
PS: I would only want to write to a binary file, not a text file, otherwise it will make no sense to encode.
EDIT1: take for example the bitstring - "10010101010010101010101011101100001001000101011110110101001010101001001010110101" Length is 80 that wld mean 10 bytes. I want to write these 10bytes into a binary file. How can I do this beginning with the bitstring?