So basically I'm building a Huffman encoding. I already have a map for storing the letter and its corresponding representation
The map is declared as
map<char, string>
So it means I have:
<'A', 101>
<'S', 000011>
<'G', 01>
...
Now, I need to encode a string, for example 'ASSGSSA', so I go to the map and get the value for each key. After that I need to WRITE the sequence of 1 and 0 (for example: 1010000011...) into a binary file but I don't know how to 'translate' each string into a bit/byte representation.
Could you please explain how can I make the transformation from string to bytes? and how to handle if the sequence hasn't size 8.