Path: utzoo!attcan!uunet!edsews!charette From: charette@edsews.EDS.COM (Mark A. Charette) Newsgroups: comp.lang.c Subject: Re: What is wrong? Message-ID: <9175@edsews.EDS.COM> Date: 25 Jan 89 12:47:38 GMT References: <2051@ndsuvax.UUCP> <9492@smoke.BRL.MIL> Organization: EDS/TSD - Troy, MI Lines: 25 In article <9492@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn ) writes: > In article <2051@ndsuvax.UUCP> numork@ndsuvax.UUCP (James Mork) writes: >> - a simple program like this, the file gets truncated after 25 or >> - 26 bytes... After 25 when I read the file back in, I just >> - get EOF (-1). What is wrong? >> > Sounds to me like a ^Z in a text stream is taken as an EOF indicator. > I know CP/M had this misfeature; maybe PC-DOS does too. > > You probably should have been using binary streams instead. > I.e. fopen with mode "wb" or "rb". PC/MS-DOS definately DOES have this misfeature. The "wb" / "rb" 'fix' as suggested by Mr. Gwyn will solve the problem (I tested at home). If a program does not have to access any files outside of it's own requirements, the use of binary modes will save a lot of headaches for PC programmers. In MS C, the default mode can be changes to binary, with the resulting CR/LF translation problems and ^Z EOF marker 'fixed'. -- Mark Charette "People only like me when I'm dumb!", he said. Electronic Data Systems "I like you a lot." was the reply. 750 Tower Drive Voice: (313)265-7006 FAX: (313)265-5770 Troy, MI 48007-7019 charette@edsews.eds.com uunet!edsews!charette