I have a char[] , named buffer , the data is stored using an ifstream in mode binary mode
,
void File::mostrarBuffer(){
for (int a = 0; a < std::strlen(buffer); a++){
std::cout << std::hex << ((int)buffer[a]) << std::endl;
}
std::cout << "===" << std::endl;
for (int a = 0; a < std::strlen(buffer); a++){
std::cout << buffer[a] << std::endl;
}
char charTest = '\211';
std::cout << "===" << std::endl;
std::cout << std::hex << (int)charTest << std::endl;
std::cout << std::hex << (int)buffer[0] << std::endl;
}
The shell displays the following:
ffffff89
50
4e
47
===
\211
P
N
G
===
ffffff89
ffffff89
File part in hexdump (" little-endian
"):
0000000 5089 474e 0a0d 0a1a 0000 0d00 4849 5244
Why does it print ffffff89
and not 89
, and only on the first element of the char []
?
this way works for me: