Home  >  Article  >  Backend Development  >  What is the legal representation of character constants in C language?

What is the legal representation of character constants in C language?

angryTom
angryTomOriginal
2020-03-09 17:00:1450158browse

What is the legal representation of character constants in C language?

What is the legal representation of C language character constants

C language character constants are characters enclosed in single quotes.

There are two ways to represent characters enclosed in single quotes:

Recommended learning: c language video tutorial

The first is Use the graphical symbol of the character, such as 'b', 'y', '*'.

The second is to use the ASCII code of the character to represent it

That is, start with a backslash (\), followed by the ASCII code of the character. The method is also called escape sequence representation. The specific method is:

has two forms:

1. Use the octal ASCII code of the character, expressed as: \101 Here, 101 is octal value.

2. Use the hexadecimal ASCII code value of the character, expressed as \xhh where hh is a two-digit hexadecimal value.

For example: 'A', '\101' and '\x41' all represent the same character constant.

The escape sequence representation can also be used to represent some special characters, to display special symbols or to control the output format.

For more C language related Introduction to Programming tutorials, please pay attention to the PHP Chinese website.

The above is the detailed content of What is the legal representation of character constants in C language?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn