FILE I/O: fread() fails for GCC(Cygnus & DJ's) and TC++

William Greathouse wgreathouse@smva.com
Sat Apr 26 07:33:00 GMT 1997


Rich Kucera wrote:

>      On Linux & MPRAS,  the sample program listed below manages to
>      read through all thirty POINT structures with no problems.
>
>      The program won't port however,  because it appears that
>      any DOS-based (FAT?) compiler (Cygnus GCC & DJ's GCC and Turbo
> C),
>      creates a binary that quits halfway through the data(15 points
> read).
>
>      I'm probably missing something about file I/O,  or it
>      could be some low-level file I/O problem.  I don't know,  help.

And that is your answer... On a DOS system there is a distinction
between "text" and
"binary" mode files that is not evident in the *NIX world.  You need to
change your
fopen mode from "r" to "rb" (for binary) and your program/data will work
together
correctly on both DOS and *NIX systems.

Bill
--
William Greathouse                | wgreathouse@smva.com  Email
SMV America, Engineering          | wgg@netcom.com        Email
8380 Darrow Road                  | (216) 425-1340 x4006  Voice
Twinsburg, OH  44087              | (216) 405-7684        FAX


More information about the Cygwin mailing list