Review: escape characters in C Language

Source: Internet
Author: User
Decimal -- decimal
Octal -- octal
Hexadecimal (HEX) -- hexadecimal
Binary -- binary

Escape characters are a special form of characters in C. Generally, escape characters are used to indicate non-printable control characters in the ASCII character set and special function characters. For example, a single marker (') is used to represent a character constant ('), it is used to represent the double apostrophes (") and backslash (\) of string constants.Escape characters are represented by a backslash \ followed by a character or an octal or hexadecimal number.

Escape Character meaning ASCII code value (decimal)
\ A bell (BEL) 007
\ B backspace (BS) 008
\ F form feed (FF) 012
\ N line feed (LF) 010
\ R press enter (CR) 013
\ T horizontal tabulation (HT) 009
\ V vertical tabulation (VT) 011
\ Backslash 092
\? Question mark character 063
\ 'Single quotes character 039
\ "Double quotation mark character 034
\ 0 null character (null) 000
\ DDD any character three octal characters
\ Xhh any character two hexadecimal

When single quotation marks and backslash are used in character constants and double quotation marks and backslash are used in character constants, escape characters must be used to represent them, that is, the backslash must be added before these characters.
In CProgramThe Escape Character \ d Or \ x H can be used to conveniently and flexibly represent any character. \ D is followed by a slash with three Octal numbers,The value of the three Octal numbers is the corresponding octal Class a s c I code value.. \ X followed by two hexadecimal numbers,The two hexadecimal numbers correspond to the hexadecimal a s c I code value of the character.

Note the following when using escape characters:
1) only lowercase letters can be used in escape characters. Each escape character can only be considered as one character.
2) The \ v vertical tabulation and the \ f tab have no impact on the screen, but will affect the printer's response.
3) when non-printable characters are used in C Programs, escape characters are usually used.

Note:
1, \ v vertical tabulation and \ f break have no impact on the screen, but will affect the printer to perform the response operation.
2, \ n should actually be called a carriage return line break. Line feed only changes one line without changing the horizontal coordinates of the cursor. Press enter to return to the beginning of the line without changing the vertical coordinates of the cursor.
3, \ t move the cursor forward four or eight cells, which can be set in the Compiler
4, \ 'is used in characters (that is, in single quotes. It is not required in the string (that is, double quotation marks). You only need to use.
5 ,\? Actually not necessary. As long as it is used? You can (verify in Windows vc6 and TC2 ).

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.