From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: C-style FILE IO problems.. Date: Sat, 21 Dec 1996 12:42:04 -0800 Organization: Two pounds of chaos and a pinch of salt Lines: 27 Message-ID: <32BC4B9C.76A5@cs.com> References: <59enik$foo AT news DOT luth DOT se> <32BB5A76 DOT 27EC1FC AT alcyone DOT com> <59ggmj$3l AT news DOT luth DOT se> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp106.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: Roland Nilsson DJ-Gateway: from newsgroup comp.os.msdos.djgpp Roland Nilsson wrote: > > Yes, I'm parsing binary files. I believe C FILE i/o is always in raw > mode. The only fopen() flags available are those relating to i/o > direction and overwrite, according to my djgpp function list. > I usually fopen() with "r". Have you read a C book lately? "r" opens files in TEXT mode. For binary operations, use "rb", "wb", "r+b", "w+b", etc. This is almost certain to be the cause of your problem. Have you even tried reading the libc docs??? I just looked in the fopen() docs and saw an explicit description of the mode string and what the values mean, including a clear mention of text and binary modes. RTFM! -- John M. Aldrich * Anything that happens, happens. * Anything that, in happening, causes something else to happen, causes something else to happen. * Anything that, in happening, causes itself to happen again, happens again. * It doesn't necessarily do it in chronological order, though. --- Douglas Adams