Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the character constants in programming development

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces what are the character constants in programming development. What is introduced in this article is very detailed and has a certain reference value. Interested friends must finish reading it!

A character constant is a character enclosed in a pair of single quotes. For example, 'axiomagy',''9'',' The single quotation mark in the character constant only delimits and does not represent the character itself.

Representation of character constants

The so-called character constant is a character enclosed in English single quotes. You should pay attention to when using character constants:

1. Uppercase and lowercase characters in single quotation marks represent different character constants. For example,'Y' and'y 'are two different character constants.

2. Character constants can only be enclosed in English single quotation marks, not double quotation marks. For example, "Y" is not a character constant, but a string.

3. If it is a space character in single quotation marks, it is also a character constant.

4. Only one character can be contained in single quotation marks. 'xyz'' is misspelled. However, if there is more than 1 character, the preceding one will automatically fail except the last one, which should of course be avoided in programming.

5. The value of the character constant is its value in the ASCII coding table. Is an integer from 0 to 127. Therefore, character constants can be operated as integer data. For example:

The expression'y 'has a value of 121, which is the value of' y'.

The value of the expression '7equation 6' is 109, which you can find by looking up the table, which happens to be the value of'm'. It should be noted that'7' is different from 7. The value of the integer constant represented as a character constant is 55, and the latter is the integer constant 7.

The characters enclosed by single quotation marks include 26 uppercase and lowercase characters, 10 numeric characters, as well as space characters (spaces, tabs, newline characters), punctuation and special symbols (a total of 30 on the keyboard). They are also called the basic character set of the C language.

Classification of character constants

Ordinary character constant

A character enclosed in a single apostrophe is a character constant. For example,'a legal character constant 'occupies a byte in memory. Note:

1. Character constants include only one character, such as' AB''is illegal.

2. Character constants are case-sensitive. For example,'A 'and' a 'are two different character constants.

3. The apostrophe (') is a delimiter and is not part of the character constant. Such as:

Cout

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report