Joke Collection Website - Public benefit messages - Carriage return in java
Carriage return in java
Carriage return and line feed
Today, I finally understand the origin and difference between "carriage return" and "line feed".
Before the advent of computers, there was something called Model 33 Teletypewriter, which could type 10 characters per second. But it has a problem, that is, it takes 0.2 seconds to type a new line, just two characters. If a new character appears within 0.2 seconds, it will be lost.
So, the developer thought of a way to solve this problem, that is, adding two characters after each line to indicate the end. One is called "Enter", which tells the typewriter to position the print head at the left margin; The other is called "line feed", which tells the typewriter to move the paper down one line.
This is the origin of "line feed" and "carriage return", and we can also see a thing or two from their English names.
Later, the computer was invented and these two concepts were extended to computers. At that time, memory was very expensive, and some scientists thought it was too wasteful to add two words at the end of each line. Just add one. As a result, there was disagreement.
In Unix system, there is only "",namely "\ n ";; In the Windows system, each line is marked with "< return to train >", that is, "\ r \ n ";; In the Mac system, every line ends with "". A direct consequence is that if you open a file under Unix/Mac system in Windows, all the words will become one line; When opening a file in Windows under Unix/Mac, there may be an M symbol at the end of each line.
C language programming (windows system) \r is to return to the beginning of this line, which will overwrite the output of the previous line.
For example:
int main() {
Cout & lt& lt hahaha "<& lt" \ r"<& lt Xixi ";
}
Finally, only Xixi is displayed, covering hahaha.
\n is carriage return+line feed. Move the cursor to the beginning of the line, and then move to the next line, that is, the beginning of the next line.
int main() {
Cout & lt& lt hahaha "<& lt" \ n"<& lt Xixi ";
}
Then display
hahaha
I summarized it myself.
/t is equivalent to the Tab key of the keyboard, /n new line, /r enter, and the basic concept should be that enter means to go back to the front, and line feed means to change a line.
Different operating systems have different line breaks:
/r Mac
/n Unix/Linux
/r/n Windows
- Previous article:Are there any jokes or games that can make people laugh?
- Next article:How to say blessing words to celebrate the Mid-Autumn Festival?
- Related articles
- How about Yangzhou Xinrui Investment and Financial Consulting Co., Ltd.?
- How to open SMS reminder of bank card?
- Hubei traffic police should take secondary responsibility for the violation of high-speed parallel lines. Do you think this is fair?
- What is the format and model of news message?
- How can girls get the sense of security they want?
- What do I need to log in to League of Legends on Pocket?
- What is the final ending of the third part of "Two Masters"?
- A primary school in Shandong requires parents to download government apps. What does this software do?
- How to cancel the mobile newspaper service by SMS?
- Help: how to apply for SMS gateway