Hopefully this is a simple question. I searched out for it, but found nothing. Basically I just need to know some simple info.
Basically I am reading in a file in binary using ifstream. All is fine and good, then I hit some spaces, and then it gets all wacky from there.
I setup a char array of 4 bytes and read in 4 bytes at a time. This works for a while until I hit a part of the file and then it starts to read spaces and messes up what I am reading.
So for example:
then it hits a line with a space, ( I can see the raw file as well, and in a hex editor it ignores these, so I can assume there is a way to decide what is a is not a space / \n), and then gets a little funky...Code:char *tempPtr; char tempVal; in.read( tempVal, 4 ); //say for instance a line in hex 34F2 //format the string into hex long value = strtol( tempVal, &tempPtr, 16 );
same code as before, on a particular 8 bytes...
Code:char *tempPtr; char tempVal; in.read( tempVal, 4 ); //line is 0000 0106 0DEE 05AB //format the string into hex CString temp; temp.Format( "%02X%02X%02X%02X", tempVal, tempVal, tempVal, tempVal ); in.read( tempVal, 4 ); // read in the second part of the above line //format the string into hex CString temp1; temp1.Format( "%02X%02X%02X%02X", tempVal, tempVal, tempVal, tempVal ); CString joined = temp + temp1;
This should come out as normal, but when I hit the spaces it comes out more like this...
0000 0106 0DFFFFEEFFFF05AB
which to me seems impossible, but hey, I am no expert either .
Any simple mistakes anyone sees with that? I am hesitant to eradicate all FF's ( space in ascii ) because there are of course numbers which have FF in them. Any ideas on this? I am kinda not able to spot it, but perhaps someone has a good way to id them. Thanks!