In a sample c++ code I will open a file and print each char in hexa file has only 16 chars but why ffffff will print after each heax values?
char buff[256];
// buff filled with fread
for(i=0;i<16;i++)
printf("%x",buff[i]);
Output is:
4affffff67ffffffcdffffff
Why is this?
Edit:
printf("%x", (int)(*(unsigned char*)(&buff[i])) );
This should make the trick. My first version was incorrect, sorry. The problem is in the sign bit: every value more than 127 was handled as negative. Casting to unsigned char should solve the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With