K
kolmogolov
hi,
it's not really an endian problem. I think I must
be missing something else ...
The problem can be reduced to different
results of the following two segments of codes:
(cut and pasted verbatim)
1.
*width = (unsigned char) fgetc(fp) +
256 * (unsigned char) fgetc(fp) +
65536 * (unsigned char) fgetc(fp) +
16777216L * (unsigned char) fgetc(fp);
yields *width == 131072 which should have been 512 for
fp points to the byte sequence of "00 02 00 00" while
2.
*width =(unsigned char) fgetc(fp);
*width += 256 * (unsigned char) fgetc(fp);
*width += 65536 * (unsigned char) fgetc(fp);
*width += 16777216L * (unsigned char) fgetc(fp);
results in the expected value 512.
What am I missing? It's driving me .......
Thanks for any hint!
it's not really an endian problem. I think I must
be missing something else ...
The problem can be reduced to different
results of the following two segments of codes:
(cut and pasted verbatim)
1.
*width = (unsigned char) fgetc(fp) +
256 * (unsigned char) fgetc(fp) +
65536 * (unsigned char) fgetc(fp) +
16777216L * (unsigned char) fgetc(fp);
yields *width == 131072 which should have been 512 for
fp points to the byte sequence of "00 02 00 00" while
2.
*width =(unsigned char) fgetc(fp);
*width += 256 * (unsigned char) fgetc(fp);
*width += 65536 * (unsigned char) fgetc(fp);
*width += 16777216L * (unsigned char) fgetc(fp);
results in the expected value 512.
What am I missing? It's driving me .......
Thanks for any hint!