C 字符常量C Character Constants

“字符常量”通过在单引号 (' ') 内封闭可表示的字符集中的单个字符来构成。A "character constant" is formed by enclosing a single character from the representable character set within single quotation marks (' '). 字符常量用于表示执行字符集内的字符。Character constants are used to represent characters in the execution character set.

语法Syntax

character-constantcharacter-constant:
“ c-char-sequence ”' c-char-sequence '

L” c-char-sequence “L' c-char-sequence '

c-char-sequence:c-char-sequence:
c-charc-char

c-char-sequence c-charc-char-sequence c-char

c-char:c-char:
除单引号 (')、反斜杠 (\) 或者换行符以外的所有源字符集成员Any member of the source character set except the single quotation mark ('), backslash (\), or newline character

escape-sequenceescape-sequence

escape-sequence:escape-sequence:
simple-escape-sequencesimple-escape-sequence

octal-escape-sequenceoctal-escape-sequence

hexadecimal-escape-sequencehexadecimal-escape-sequence

simple-escape-sequence: one ofsimple-escape-sequence: one of
\a \b \f \n \r \t \v\a \b \f \n \r \t \v

\' \" \\ \?\' \" \\ \?

octal-escape-sequence:octal-escape-sequence:
\ octal-digit\ octal-digit

\ octal-digit octal-digit\ octal-digit octal-digit

\ octal-digit octal-digit octal-digit\ octal-digit octal-digit octal-digit

hexadecimal-escape-sequencehexadecimal-escape-sequence:
\x hexadecimal-digit\x hexadecimal-digit

hexadecimal-escape-sequence hexadecimal-digithexadecimal-escape-sequence hexadecimal-digit

另请参阅See Also

C 常量C Constants