fread() portability problem
Shores
shores at fergvax.unl.edu
Tue Jun 25 11:57:40 AEST 1991
I'm hoping this problem is only with ultrix. Let's say I have fopen()ed
a file and the first 2 bytes are 0x0006. Now on my mac (and a NeXT) I
can say fread (&twoBytes, 2L, 1L, inFile) and it will put the number 6
into a 2 byte integer, like I want. But when I port this code to a VAX
running ultrix, the same statement puts 0x0600 into the integer!
I would like to post my finished code and have it run on a wide array of
unix machines; are other machines going to give me this problem too, or
is this just because ultrix is acting obnoxious? I'm about to try to
replace my fread calls with a bunch of ugly getc()s, like create a
getword() which calls getc() twice, and return (char1 << 8) + char2.
I'd sure hate to resort to using this method, so if anyone has any ideas
I would like to hear them (by email).
Thanks!
Tom... Tommy... Thomas... the Tom-ster, the Tom-boy, the Tomminator...
... Tom Shores, Department of Mathematics, University of Nebraska.
... shores at fergvax.unl.edu
More information about the Comp.lang.c
mailing list