Hello. I'm having trouble with file io. Hopefully someone can help.
I don't know if anyone here knows much about huffman or arithmetic compression, but basically, you generate a sequence of bits and ship out groups of eight (bytes) to a file.
My alphabet is extended ascii. I guess I'm supposed to be able to read and write any and all these characters. But I'm having problems:
For example, in one program, the encoder was supposed to send the number of encoded characters as a 32 bit number to the output file. So I have a file with 26 characters. I convert this to binary and send out the bytes, least significant byte first:
Binary: 00011010 00000000 00000000 00000000
Ascii Character: Substitution NULL NULL NULL
HEX: 1A 00 00 00
I can send this out to a file just fine, but I CAN'T read all the characters (at the decoder).
I'm using the fstream library (using ifstream, ofstream), and when I try to read in some of these "non-printable" characters, my stream fails and I can't do squat. It doesn't matter if i try reading it in to an integer variable or a char. I have to be able to read all the bytes.
Is there some way around this?