Enter the story with the line break

Source: Internet
Author: User

Before learning to compile, always do not know the teacher in the line, always hit a newline character and carriage return , originally they have such a story ....

A long time ago, there was a machine called a Telex typewriter (teletype Model ASR) , and there was no such thing as a computer. On this typewriter, there is a part called carriage , it is the type head, the equivalent of the typewriter cursor. Each character is entered, and the cursor advances one cell. When you enter a word Fu a line, the cursor re-prints from the leftmost side of the next line .

This time will trigger two actions, one is to move the cursor in the vertical direction, one is the horizontal direction of the cursor to the leftmost. Then the typewriter can be 10 characters per second, equivalent to 0.1 seconds to play a character, and to complete these two actions will take 0.2 seconds, if in this 0.2 seconds, if there are new characters sent over, then these characters will be lost.

To address this missing character, the developer adds two characters after each line that indicate the end of a line: a return (carriage return), equivalent to telling the typewriter to move the cursor horizontally to the far left; a line Feed), which is equivalent to telling the typewriter to move the cursor to the next line in the vertical direction.

This is the origin of the carriage return and line breaks .

Later, the computer appeared, the two concepts were also taken over. But when the storage device was very expensive, some people thought that using two characters to denote the end of a line was very wasteful, so a branch was created, and different vendors had different ways of handling it.

In these operating systems, the UNIX operating system ends with a newline at the end of each line, which is "\ n"; Windows is a carriage return + newline , that is, "\ r \ n", while the Mac system uses a carriage return to represent the end, that is, "\ r".

It is for this reason that we sometimes use the Windows system to open Unix/mac system files when all the text becomes a line, while the UNIX and Mac systems open the Windows system files, at the end of each line will be a ^m The character.

Finish

Pay attention to the public my number: hard yards of farmers , get more original articles, backstage reply gift package to send you a special resource package.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.