Mail Archives: djgpp/1998/10/08/20:19:48
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 ;-).
- Raw text -