Date: Thu, 1 Oct 1998 21:29:04 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Graeme Fenwick cc: djgpp AT delorie DOT com Subject: Re: Strange problem reading/writing binary files. In-Reply-To: <004801bdecbb$bb65eaa0$7c2f70c3@kgwujunl> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 30 Sep 1998, Graeme Fenwick wrote: > Problem is, that regardless of whether the file is written in text ("w") or > binary ("wb") mode, when it comes to displaying the file, it *always* stops > at the CTRL-Z, regardless of mode. This is a ``feature'' of DOS: when you write to the console device in the default ``cooked'' mode, ^Z is interpreted as end-of-file. To avoid this, switch the console device to binary mode, which has a side effect of putting the console into so-called ``raw'' mode, like this: setmode(1, O_BINARY); WARNING: doing the above has some nasty side effects; for example, you cannot interrupt the program with Ctrl-C if its console is in raw mode. So I suggest to call `setmode' immediately before you begin writing to the console, and call "setmode(1, O_TEXT)" immediately after you finish displaying the text. > (Just a thought, but does this have anything to do with DJGPP's Unix-based > origins, since UNIX doesn't have separate text and binary files?) No, this is a gift straight from uncle Bill ;-).