Character literals
A character literal contains a sequence of characters or
escape sequences enclosed in single quotation mark symbols, for example
'c'. A character literal may be prefixed with the
letter L, for example L'c'. A character literal without
the L prefix is an ordinary character literal or a narrow
character literal. A character literal with the L prefix is a wide
character literal. An ordinary character literal that contains
more than one character or escape sequence (excluding single quotes
('), backslashes (\) or new-line characters) is a multicharacter
literal.
The
type of a narrow character literal is int. The type
of a wide character literal is wchar_t. The type
of a multicharacter literal is int.
The
type of a character literal that contains only one character is char,
which is an integral type. The type of a wide character literal is wchar_t.
The type of a multicharacter literal is int.
At least one character or escape sequence must appear in the character literal, and the character literal must appear on a single logical source line.
The characters can be from the source program character set. You
can represent the double quotation mark symbol by itself, but to represent
the single quotation mark symbol, you must use the backslash symbol
followed by a single quotation mark symbol ( \' escape
sequence). (See Escape sequences for a list
of other characters that are represented by escape characters.)
The
value of a narrow or wide character literal containing a single character
is the numeric representation of the character in the character set
used at runtime. The lowest four bytes represent the value of an
integer character literal that contains more than one character. The
lowest two bytes of the lowest multibyte character represent the value
of a wide character literal. For the locale type LOCALETYPE(*LOCALEUTF),
the lowest four bytes of the lowest multibyte character represent
the value of the wide character literal.
Outside of the basic source character set, the universal character names for letters and digits are allowed in C++ .
'a'
'\''
L'0'
'(' 