hey, I am having problems reading binnary data. When I try to read the hex value "1a" into a string, it messes up since "1a" is a messed up character on the ascii chart. Does anyone know how I can read this into an integer?
hey, I am having problems reading binnary data. When I try to read the hex value "1a" into a string, it messes up since "1a" is a messed up character on the ascii chart. Does anyone know how I can read this into an integer?
Post a snippet of code, showing what you're trying to do, and someone will help you.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Say I have a binary file that looks like this:
19 00 00 00 01 1a 00 00 00 01 1b 00 00 00 01
I can read the file like this:
It reads the first 5 bytes but when it reaches the 1A it gets messed up. If i Change the 1A to anything else it will wok. I think the reason for this is becuase 1A is the ascii value for substitute which messes it up. So how can I read this file into integer's instead of char's?Code:char buffer[5]; for(int i = 0; i < 3; i++) { file.read(buffer, 5) cout << buffer << "\n"; }
So It would look something like this(which doesn't work)
Code:int buffer[5]; for(int i = 0; i < 3; i++) { file >> buffer; cout << buffer << "\n"; }