I'm having that probably very stupid problem, yet I can't find an answer, so ...
My application has to make a hex dump of some buffer (read from binary file). I have a pointer to that buffer:
To read it byte by byte I wrote a function
As you see, first I check whether position is not outside the buffer, then I increment buffer pointer and read the char located at calculated position.
In the main() function I have following piece of code :
Everything works fine and dumped values are correct (I compared them with Hexplorer output unless returned char's ASCII code is 255. See the output yourself:
These FFFFFFFF fields should be displayed as FF. Everything else is correct. At first, I thought I'm doing something wrong with printf(), but using cout << hex << int(sp) produced the same.
Any ideas ?
Mike
My application has to make a hex dump of some buffer (read from binary file). I have a pointer to that buffer:
Code:
char *headerPtr;
Code:
char header::getByteAtPos(int pos){
if( pos > hsize ) {
return NULL;
}
char ret = *(headerPtr + pos);
return ret;
}
In the main() function I have following piece of code :
Code:
for(int i=0,w=0; i<X->size; i++, w++) {
[cut unimportant formatting stuff]
sp = X->getByteAtPos(i);
printf("%02X ",sp);
}
Code:
4D 5A 50 00 02 00 00 00 04 00 0F 00 FFFFFFFF FFFFFFFF 00
These FFFFFFFF fields should be displayed as FF. Everything else is correct. At first, I thought I'm doing something wrong with printf(), but using cout << hex << int(sp) produced the same.
Any ideas ?
Mike