Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between \n and \r? [duplicate]

Possible Duplicate:
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?

like image 909
Moon Avatar asked Mar 13 '10 19:03

Moon


People also ask

Is \n and \r same?

historically a \n was used to move the carriage down, while the \r was used to move the carriage back to the left side of the page.

What does \r and \n mean?

\n means new line. It means that the cursor must go to the next line. \r means carriage return. It means that the cursor should go back to the beginning of the line.

What are \n \r called?

The C programming language provides the escape sequences '\n' (newline) and '\r' (carriage return). However, these are not required to be equivalent to the ASCII LF and CR control characters.

What is duplicated in r?

The R function duplicated() returns a logical vector where TRUE specifies which elements of a vector or data frame are duplicates. ! is a logical negation. ! duplicated() means that we don't want duplicate rows.


1 Answers

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

Using \r in Unix-like systems may result in overwriting the same line.

like image 100
Thom Wiggers Avatar answered Jan 03 '23 14:01

Thom Wiggers