Mail Archives: djgpp/1996/11/30/14:50:16
Gorman Ho wrote:
>
> Hey guys.
>
> I just wanted to know how many char's a newline character ('\n') is.
> Is it 2 (10 and 13) or just 1?
Inside your C program, it's 1. In the operating system, it can be any
of a number of things:
- In DOS, it's a CRLF pair.
- In Unix, it's just a CR.
- In Mac, it's something else (can't remember)
This is why it's important to distinguish between text and binary modes
when doing file i/o in C. Whatever compiler you use is _guaranteed_ to
correctly convert EOL characters to '\n' and vice versa when you are
performing text-mode operations.
In other words, don't try to write binary data in text mode, or read
text data in binary mode; there's no guarantee that it will work. This
to me is just common sense. :)
--
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I | fighteer AT cs DOT com |
| * Proud user of DJGPP! * | http://www.cs.com/fighteer |
| ObJoke: If Bill Gates were a robber, not only would he |
| shoot you, but he'd send you a bill for the bullets. |
---------------------------------------------------------------------
- Raw text -