What's the difference between \n and \r? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What's the difference between \n and \r?

Not just "new line" vs "carriage return", but, what is the difference in look / visual result?

27th Jun 2016, 3:44 AM
Leighton DeGoede
Leighton DeGoede - avatar
2 Answers
+ 8
\n Unix \r Mac \r\n Windows and DOS. In windows, the \n moves to the beginning of the next line. The \r moves to the beginning of the current line, without moving to the next line
6th Jul 2016, 6:03 PM
Mark Angelo Rivo
Mark Angelo Rivo - avatar
+ 2
\n new line \r carriage return
25th Jul 2016, 8:32 AM
jumanne amanzi
jumanne amanzi - avatar