**Cire i am sorry about that, i made some modification and now i can output FFFFFFFF FFFFFFD8 FFFFFFFF FFFFFFE0. but, i want FF D8 FF F0. Thanks for the help
if (file.is_open())
{
for (int i = 0; i < 20; i++)
{
cout << hex << uppercase << (int)block[i] << " ";
}
cout << endl;
file.close();
}
else
cout << "File could not be opened " << endl;
cout << "The program read " << file.gcount() << " bytes from the
binary file "<< endl;
file.close();
You are using signed variables. The bit pattern that makes up 0xFF is a negative number in a signed char. The sign bit is preserved when you cast the char to int. This is the root of your problems.