开发者

Odd result when reading first byte of a PNG header

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜