0

Possible Duplicate:
Difference between \n and \r?

in C/C++ I got used to the newline character being as '\n' but when I got to C# it's "\r\n", '\n' or '\r' don't write a new line on their own.

Why is that? and what's the difference between '\r' and '\n'?

Community
  • 1
  • 1
vexe
  • 5,433
  • 12
  • 52
  • 81

2 Answers2

2

From http://en.wikipedia.org/wiki/Newline:

  • LF: Multics, Unix and Unix-like systems (GNU/Linux, Mac OS X, FreeBSD, AIX, Xenix, etc.), BeOS, Amiga, RISC OS and others.
  • CR+LF: Microsoft Windows, DEC TOPS-10, RT-11 and most other early non-Unix and non-IBM OSes, CP/M, MP/M, DOS (MS-DOS, PC-DOS, etc.), Atari TOS, OS/2, Symbian OS, Palm OS
  • LF+CR: Acorn BBC and RISC OS spooled text output.
  • CR: Commodore 8-bit machines, Acorn BBC, TRS-80, Apple II family, Mac OS up to version 9 and OS-9
  • RS: QNX pre-POSIX implementation.

CRLF Was intended to be compatible with all the others.

The above all mean newline. THe original meaning was lost, even if someone had an argument for using one or the other, at some point in history.

oxygen
  • 5,891
  • 6
  • 37
  • 69
0

It should be exactly the same as C++.

However, some Windows controls require a Carriage Return/Newline pair rather than just a Newline.

\n is the newline character. \r is the carriage return character.

Matthew Watson
  • 104,400
  • 10
  • 158
  • 276