Programming in C

(Barry) #1
3.0 Constants 429

In the octal character case, from one to three octal digits can be specified. In the last
three cases, hexadecimal digits are used.

3.3.2 Wide Character Constants
A wide character constantis written as L'x'.The type of such a constant is wchar_t,as
defined in the standard header file <stddef.h>.Wide character constants provide a way
to express a character from a character set that cannot be fully represented with the nor-
mal chartype.

3.4 Character String Constants


A sequence of zero or more characters enclosed within double quotation marks repre-
sents a character string constant. Any valid character can be included in the string,
including any of the escape characters listed previously.The compiler automatically
inserts a null character ('\0') at the end of the string.
Normally, the compiler produces a pointer to the first character in the string and the
type is “pointer to char.” However, when the string constant is used with the sizeof
operator to initialize a character array, or with the &operator, the type of the string con-
stant is “array of char.”
Character string constants cannot be modified by the program.

3.4.1 Character String Concatenation
The preprocessor automatically concatenates adjacent character string constants together.
The strings can be separated by zero or more whitespace characters. So, the following
three strings
"a" " character "
"string"
are equivalent to the single string
"a character string"
after concatenation.

3.4.2 Multibyte Characters
Implementation-defined sequences of characters can be used to shift back and forth
between different states in a character string so that multibyte characters can be
included.

3.4.3 Wide Character String Constants
Character string constants from an extended character set are expressed using the format
L"...".The type of such a constant is “pointer to wchar_t,” where wchar_tis defined
in <stddef.h>.

20 0672326663 AppA 6/10/04 2:01 PM Page 429

Free download pdf