\ R \ n in windows and linux

Source: Internet
Author: User

0x0 a line feed with \ n ASCII
\ R: ASCII 0x0d press ENTER

In windows, when you press enter, it will automatically become \ r \ n
In linux, the Enter key only represents \ n
In windows, the Return key is \ r \ n.
\ N is to enter the next line, \ r is the print header and return to the first line
In linux/unix, only \ n is used. It indicates carriage return + line feed.
In windows, \ r Only returns a carriage return without line breaks. \ n is a line break, but in some edits, a separate \ n does not wrap a line (such as notepad)

Generally, \ n can be written in a program. In linux or windows, the carriage return + line feed function can be implemented. (In a text file, linux only has 0x0a, windows will automatically change to 0x0d 0x0a)
Example: www.2cto.com

# Include <stdio. h>
Int main ()
{
Char a [10] = "abc \ r ";
Printf ();
Return 0;
}
The program runs without any output.
The reason is that \ r press ENTER indicates that the print header is returned to the starting position of the row, thus overwriting abc, so there is no output on the console!


From Jiang Yafeng's CSDN blog

Related Article

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.