开发者

Odd result when reading first byte of a PNG header

开发者 https://www.devze.com 2023-02-06 05:44 出处:网络
I\'m trying to read the header from a PNG file. The result sho开发者_运维问答uld be Dec: 137 80 78 71 13 10 26 10

I'm trying to read the header from a PNG file.

The result sho开发者_运维问答uld be

Dec: 137 80 78 71 13 10 26 10
Hex: 89 50 4E 47 0D 0A 1A 0A

However, I get

Dec: 4294967 80 78 71 13 10 26 10

What am I doing wrong?

Code:

char T;
pngFile = fopen(Filename, "rb");
if(pngFile)
{
    fread(&T, 1, 1, pngFile);
    fclose(pngFile);
    printf("T: %u\n", T);
}


137 is too big for signed char - use unsigned char instead...

see this link for limits of data types.

0

精彩评论

暂无评论...
验证码 换一张
取 消