About escape characters in the C language

Source: Internet
Author: User

The escape character is literally understood to translate the meaning of the subsequent character.
Example: Commonly used escape characters
Hex and octal: \DDD:DDD is 3 contiguous 8 binary data So what he meant was to escape the characters in the back, meaning that instead of printing the DDD3 numbers directly, we printed the characters in the ASCII table, and DDD was actually the numbering in our ASCII table.

Octal notation: \xhh:hh represents two-bit 16 binary data, so what he means is to escape the two-bit hexadecimal data, showing the ASCII representation of the character graphic corresponding to the number.

Note that there is no decimal representation, but some are able to use decimal notation, for example, our-to-end character is an example.

Other escape characters apply: \ n \ \f \ \ \ \ etc
Because ' "\ These characters themselves are not only displayed as a character, but have some other characteristics, so we are here with the escape character to escape him, do not let it express this feature, but simply as a character to display.

It is important to note that the encoding in the ASCII encoding table and the corresponding character graphic, the encoding in the ASCII encoding table and the corresponding meaning
Why do you say that? Because there are actually some encodings in the ASCII encoding table that are capable of displaying characters, while others are not capable of displaying characters, they have a specific effect, such as our end-of-line character, \ n newline character ....

One issue that needs attention is also a knowledge point that is often learned: character numbers and true numbers
For example: ' 0 ' is a character number 0 is a real number
char a = ' 0 '; Char b = 0; So how does this make sense? When we give a number to a variable of type char, then he will think of that number as the encoded value in the ASCII table, so if we are a the case is that the character is displayed as 0 of the encoded value to a, that is, the decimal 48, and the encoded value of 0 to B.
When we use%d to print out is the corresponding encoding value, if you use%c to print out the corresponding character graphic display.
So here is the conversion formula involving a character number and a positive number: Character number-48 = true number

About escape characters in the C language

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.