--- In [email protected], veeru sagar <[EMAIL PROTECTED]> wrote: > > Hello, > I am working on huffman coding in which fixed size bit length > charcters are converted to variable size bits. > > I can read the charcters from one file of size 8 bits,but i > want to convert it to variable size from 4 bits to 12 bits. > How i can write this variable size bits in the other file. <snip>
It would be a nice thing if you would inform us when you cross-post. If you would have done, I would have prepared my answer in a text editor and simply pasted it to two different groups (or maybe more if I were Paul Herring). O.k., here's my reply from cprogramming2: <begin of quote> The only way I know is to assemble the output bytes yourself. Meaning you will have to keep track of how many bits of the current output byte you already used, attach as many bytes from the currently converted character to this byte, if eight bits are full, output this byte to the compressed file, and fill the byte buffer (or buffer byte? I think that doesn't matter) with the remaining bits from the byte currently being processed. Meaning: much work with the bit operators under C/C++. <end of quote> Regards, Nico
