First, let’s talk about the difference between r and n
The origin and difference of the two concepts "Carriage Return" and "Line Feed".
Before the advent of computers, there was something called a Teletype Model 33 (the concept of tty in Linux/Unix comes from this), which could type 10 characters per second. But it had a problem. It takes 0.2 seconds to type a new line, which is enough to type two characters. If a new character is transmitted during this 0.2 seconds, then this character will be lost. The staff came up with a way to solve this problem, which was to add two end characters after each line. One is called "carriage return", which tells the typewriter to position the print head at the left border; the other is called "line feed", which tells the typewriter to move the paper. Move down one line. This is the origin of "line feed" and "carriage return", which can be seen from their English names
Later, the computer was invented, and these two concepts were also used. Generally on computers. At that time, memory was very expensive, and some scientists thought that adding two characters at the end of each line was too wasteful. So, there was a disagreement. The end of the line is only "
When programming in C language (windows system)
r is return to the beginning of this line. This will return this line. The previous output is overwritten.
For example: (Note that the following is C++ code)
Only xixi is displayed in the end, and hahaha is overwritten.
Copy code.