There's another possible way of solving this problem. From readHeader() we get the freqs vector. And from this, we add up all the frequencies of each character so we know the number of ascii characters in the file. Call that number blah, then blah will also be the number of times you will traverse the Huffman tree to find the character that corresponds with each bitstring. Make a counter=0, then everytime you are at the leaf, increment counter by 1 and stop when counter = blah. If you built the Huffman tree correctly, the remaining bits won't be read. Thus, you end up not modifying the readHeader() or making an psuedo-EOF. |