Question: > 
> **Possible Duplicate:**  
> 
> [What is the difference between \r and \n?](https://stackoverflow.com/questions/1279779/what-is-the-difference-between-r-and-n) 
> 
> 
> 

Hi,

What is difference between `\n` (newline) and `\r` (carriage return)? They both move current cursor to the next line. Are they same?

Answer: 
`\r` returns the cursor to the beginning of the line, NOT to the next line. When you use `\n`in Linux, `\r` is implied, in windows, it is not.

Using `\r` in Unix-like systems may result in overwriting the same line.
Ah the old days of the typewriter...

The difference between the two stems from days of yonder when typing was done directly to paper. It required two actions to go to the next line:

1. pushing the 'carriage' (big cilinder on the top) back to the left (this is where the character would end up).
2. shifting the paper one line up. (thus going down one line)

Splitting these two actions facilitated going back to a precise character position to correct it (there was no way to go up one line, or left one character!). Holding paper whiteout on the erroneous character and hitting that key would neatly whiteout exactly that erroneous character, then you could go back again and hit the correct key
(there was a key for not moving the carriage though).

In the young computer age these actions were translated 1 to 1 into `\r` for carriage return and `\n` for shifting the 'paper'.

Nowadays the major operating systems apparently have differing opinions on whether this is still necessary for computer technology where going back to previous position is much easier. However, in modern programming languages you'll generally see that `\n` is assumed to mean `\r\n`.