Can cPP force it to read and write according to one character of 8bit when reading and writing the file?

The

scenario is the operation of
a Huffman coding tree. The so-called Huffman coding is to re-encode the characters in the text with 0 and 1 in a certain way, in which more characters use fewer digits. For example, the letter e appears a lot in this text, and the encoding assigned to it may be 01, while the letter s appears less, and the encoding for it may be 011110.
because I can"t read and write bit to the file directly (recommended if there is a way or a mature library), so we have to store all the characters of the file into 0 or 1 in a string, and then store every 8 characters in the string. Because these eight characters are all made up of 01, if you treat this paragraph as a binary number, you can get a number between 0 and 255. then convert this number to char and then output it to a file..
then the problem arises, and now I"m going to read my output from this file (obviously it will be a lot of garbled code if I look at it directly).
it doesn"t matter whether it"s garbled or not. Anyway, I read it and put it in a string, and then each character corresponds to a number of 0-255. then I turn this number back to the binary string and put it together, so I get the Huffman code again. It turns out that I can"t go back to this step.
my personal idea is that maybe when I read it, cPP looks confused and doesn"t know what kind of coding it is going to follow and what J8 stuff it is reading, so what I read back is wrong. If you can tell cPP, you can read it according to the character 8bit. You don"t need to worry about what exactly is read in. I think it can solve this problem, right?
Thank you

.

it is recommended that you take a look at CPP's method of reading files. In fact, reading files in various languages is first binary, followed by conversion to other types. Furthermore, you need to understand that there is a fundamental difference between a binary array and an array of strings "0" and "1". If you can't handle this difference, you won't be Hoffman compressed, and your final file will definitely be bigger.


in the final analysis, we have to rely on binary reading and writing files to solve this problem.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e46b1e-44be1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e46b1e-44be1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?