Newsgroups: comp.lang.c Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!maverick.ksu.ksu.edu!unlinfo.unl.edu!fergvax!shores From: shores@fergvax.unl.edu (Shores) Subject: fread() portability problem Message-ID: Keywords: fread Sender: news@unlinfo.unl.edu Nntp-Posting-Host: fergvax.unl.edu Organization: University of Nebraska - Lincoln Date: 25 Jun 91 01:57:40 GMT Lines: 19 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@fergvax.unl.edu