I'm creating a basic Huffman encoding/decoding tool. I've found this question which helped me implement a header that stores my generated huffman tree in binary form. I can also use the tree to encode/decode a text into a binary file as well. So the program actually works, but I still have a problem.
Currently the header and the encoded binary are in separate files because I cannot figure out a way to put them into the same file in a way that makes it easy for me to read the header at the start of the decoding procedure. Hard coding in some "end of header" character seems like a rather hacky way to do this, not to mention that there is the possibility that the some initial bits of the terminating character might be read in as part of the encoded tree in the header, causing the entire tree to get corrupted.
Although my program works with separate header and body files, I'd like to merge them. Any ideas on how I can do this?