Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-lcc!ames!mailrus!purdue!decwrl!sun!rayssd!srhqla!tcm From: tcm@srhqla.UUCP (Tim Meighan) Newsgroups: comp.lang.c Subject: Re: What is wrong? Message-ID: <320@srhqla.UUCP> Date: 26 Jan 89 20:01:58 GMT References: <2051@ndsuvax.UUCP> <8828@alice.UUCP> Reply-To: tcm@srhqla.UUCP (Tim Meighan) Distribution: na Organization: Silent Radio, Los Angeles Lines: 25 In article <8828@alice.UUCP> ark@alice.UUCP (Andrew Koenig) writes: >In article <2051@ndsuvax.UUCP>, numork@ndsuvax.UUCP (James Mork) writes: >> I am using TC 1.5 everything was going OK... Now... when I run >> a simple program like this, the file gets truncated after 25 or > >Some MS-DOS C compilers treat a ^Z character as end of file. My understanding is that the end-of-file indication is being generated by DOS and returned to the program; the compiler has nothing to do with it. This happens when the file is opened in text rather than binary mode, which causes DOS to interperet ^Z as an EOF marker, among other things. In binary mode, DOS passes all characters without interpretation. Also, I noticed a suggestion in another posting that James use fopen() to solve the problem. This could mean re-writing a lot of code, since fopen() and open() use different file handling techniques. While I am not familiar with the TC compiler, it should allow you to open() a file in binary with the "b" argument thus: fp=open("MYFILE.TXT","r+b"); Tim Meighan Network Operations Silent Radio