Special characters (\ t, \ r, \ n) in Linux and Windows)

Source: Internet
Author: User
Special characters (\ t, \ r, \ n) in Linux and Windows -- Linux general technology-Linux programming and kernel information. For more information, see the following. Today, I wrote a Test Program (running in a Linux environment), in which some command strings must be pre-stored in a file, and then the test program reads these command strings from the file. In these command strings, fields are separated by the "\ t" separator. The end of each command string must end with "\ r \ n.

At the beginning, I simply put such a command string, such as "305 \ t00: 14: 22: 9C: 22: 9B \ t10.1.10.17 \ t \ r \ n "is saved to the file. However, when running the test program, the Command Format always prompts an error. I initially thought there was a problem with the function that reads the command string from the file, but after repeated experiments, I found that it was not a problem to read the file. By printing and displaying each character of the read string, I suddenly thought that the Delimiter is stored as a separate character in the file, rather than what they mean. ("\ T" is '\' and 't', rather than the TAB key)

Now that the problem is found, you can directly type the Tab key and the Enter key when saving the file. However, the return key in linux only represents "\ n", while the return key in windows represents "\ r \ n". Therefore, create the command string file in windows and upload it to linux. The problem is finally solved.
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.