Firstly, I apologize for any English mistakes that I make, but being 15 and French doesn't help ...
I am trying to program a PNG decoder using the file format specification ( http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html ), but I ran into a weird problem.
The specification states that the first eight bytes of the PNG file always contain the following (decimal) values: 137 80 78 71 13 10 26 10.
When I test this simple program:
int main()
{
ifstream file("test.png");
string line;
getline(file, line);
cout << line[0] << endl;
}
The output is ë, which represents 137 in the ascii table. Well, it matches the first byte.
However, when I do int ascii_value = line[0];, the output value is -119, which is not the correct ascii value.
"e", ascii.
- , ? , ascii, .
! char !