I'm implementing Huffman encoding in c++ and I can successfully build a Huffman tree and can encode/decode strings.
The next thing I want to do is be able to encode/decode files, but I have a few problems. I'm using bool vectors to contain the code words. My problem is: I can only write bytes to a file. How do I write bit by bit? Is there perhaps a library I can use?
The other thing is, that if I want to decode a file I need the the tree itself (or the code table). What's the best way to serialize the tree?
Any help would be much appreciated.