'\ R' is the carriage return,' \ n' is the line feed, the former causes the cursor to the beginning of the line, and the latter causes the cursor to move down one cell. Generally, two keys are used together.
Carriage Return and line feed
In Unix systems, each line ends with "<line feed>", that is, "\ n". In Windows systems, each line ends with "<line feed> <press enter> ", that is, "\ n \ r". In MAC systems, the end of each line is "<press enter> ".
One direct consequence is that if a file in UNIX/MAC is opened in windows, all the text will be changed to a line; if a file in Windows is opened in UNIX/MAC, A ^ m symbol may be added at the end of each line.
In C language programming (Windows System), \ r means return to the beginning of the line. This overwrites the previous output of this line.
For example:
Int main (){
Cout <"HAHAHA" <"\ r" <"Xixi ";
}
At last, only Xixi is displayed, and hahaha is overwritten.
\ N is the carriage return + line feed. The cursor is first moved to the beginning of the line and then switched to the next line, that is, to pull the first line of the next line.
Int main (){
Cout <"HAHAHA" <"\ n" <"Xixi ";
}
Display
Hahaha
Xixi
Differences between "\ n" and "\ r" in the code