problem in saving Huffman Code?
I want to save Huffman codes into a file. How can I do this? I am saving Huffman codes into a string but size of generated file is bigger than Original file. A very simple approach is to write one bit at a time with something like the following: unsigned char acc; // Accumulator of bit waiting to be written int bitcount; // How many bits are aready present in the accumulator // write a single bit (0/1) void writebit(int bit) { acc |= (bit << bitcount); if (++bitcount == 8) { writebyte(acc); acc = 0; bitcount = 0; } } to read back a sigle bit the procedure is symmetrical unsigned char acc; //