Comments, Identifiers, Keywords, Constants


参考书:

The C Programming Language (K&R, second edition)

Comments

The characters /* introduce a comment, which terminates with characters */.

Comments do not nest, and they do not occur within string or character literals.

Identifiers

An identifier is a sequence of letters and digits, The first character must be a letter; the underscore _ counts as a letter.

Upper and lower case letters are different.

Keywords

The following identifiers are reserved for use as keywords, and may not used otherwise:

在这里插入图片描述

Constants

Integer Constants

An integer constant consisting of a sequence of digits is taken to be octal if it begins with 0 0 (digit zero), decimal otherwise.

A sequence of digits preceded by 0 x 0x of 0 X 0X (digit zero) is taken to be a hexadecimal integer.

An integer constant may be suffixed by the letter u or U, to specify that it is unsigned. It may also be suffixed by the letter l or L to specify that it is long.

Character constants

A character constants is a sequence of one or more characters enclosed in single quotes, as ‘x’.

The value of a character constant with only one character is the numeric value of the character in the machine’s character set at execution time.

The value of a multi-character constant is implementation-defined.

Escape sequence:
在这里插入图片描述
The escape \ooo consists of the backslash followed by 1, 2, or 3 octal digits, which are taken to specify the value of the desired character.

Floating constants

A floating constant consists of an integer part, a decimal point, a fraction part, an e or E, an optional signed integer exponent and an optional type suffix, one of f, F, ;, or L.

The integer and fraction parts both consist of a sequence of digits.

Either the integer and fraction part (not both) may be missing; either the decimal point or the e and the exponent (not both) may be missing.

The type is determined by the suffix; F or f makes it float, L or ; makes it long double; otherwise it is double.

Enumeration Constants

Identifiers declared as enumerators are constants of type int.

发布了120 篇原创文章 · 获赞 2 · 访问量 5802

猜你喜欢

转载自blog.csdn.net/Lee567/article/details/103252096