The difference between carriage return and line feed is the difference between carriage return and line feed.
I have never been very clear about the difference between carriage return and line break.
Now I understand it clearly. Take a note.
Symbol ASCII code meaning
\ N 10 line feed NL
\ R 13 press ENTER CR
Press enter \ r. The original meaning is that the cursor returns to the beginning of the line. r returns the English return. The control character can be written as CR, that is, Carriage Return.
Line Feed \ n refers to the next Line of the cursor (not necessarily to the beginning of the next Line). n is an English newline. The control character can be written as LF, that is, Line Feed.
In differentOperating SystemThese two characters are different. For example, in the WIN system, these two characters are the meanings of the representation. In UNIX systems, line feed \ n is represented by the cursor next line and return to the beginning of the line, on MAC, \ r returns to the beginning of the line and goes down one line. The definition of the ENTER key is related to the operating system. Generally, two keys are used together.
Before the computer appeared, there was a kind of device called Teletype Model 33, which can contain 10 characters per second. But there is a problem, that is, when a line breaks a line, it takes 0.2 seconds, just two characters. If a new character is passed in the 0.2 s, the character will be lost.
As a result, the developers thought of a way to solve this problem, that is, adding two end characters after each line. One is "enter", which tells the typewriter to position the print head on the left boundary, and the other is "line feed", which tells the typewriter to move the paper down one line.
This is the source of "line feed" and "Carriage Return". They can also be seen in their English names.
Later, computers were invented, and these two concepts were invented on computers. At that time, memory was very expensive. Some scientists thought it would be too waste to add two characters at the end of each line. Just add one character. As a result, there were differences.
/* ===================================================== */
\ N: End of the UNIX system line
\ N \ r: End character at the end of the window system line
\ R: The end of the mac OS system line
/* ===================================================== */
One direct consequence is that files in Unix/Mac systems are stored inWindowsAll the text will be changed to one line. If a file in Windows is opened under Unix/Mac, a ^ M symbol may be added at the end of each line. (This is also a common phenomenon. It turns out to be like this)