Mail Archives: djgpp/1998/02/01/19:16:28
Noam Rotem wrote:
>
> Hi,
>
> What is the difference, from the implementation side, between a text file and a binary
> one? Does djgpp mark EOF differently in a text file and a binary file? Is there any
> difference in the way the stream is buffered or treated? And, BTW, are stdin / stdout
> *text* streams? (I understand the logical differences between the two kinds, but not the
> actual compiler job around each one).
Text mode under DOS has two main differences from binary mode. First,
the EOF character (Ctrl-Z) signals the end of the file in text mode.
Second, MS-DOS text files signal EOL with a CR/LF pair. When reading
such a file into memory, the extra LF is automatically stripped.
Likewise, when writing a text file, EOF terminates the write, and CR's
are translated into CR/LF.
The moral of the story: If you are writing text data, use text mode.
If you are writing binary data, use binary mode. Do NOT mix the two, or
your programs will almost certainly fail.
--
---------------------------------------------------------------------
| John M. Aldrich | "Animals can be driven crazy by pla- |
| aka Fighteer I | cing too many in too small a pen. |
| mailto:fighteer AT cs DOT com | Homo sapiens is the only animal that |
| http://www.cs.com/fighteer | voluntarily does this to himself." |
---------------------------------------------------------------------
- Raw text -