56
Section 2: Compiler
TI
-
89 / TI
-
92 Plus Sierra C Assembler Reference Manual Not for Distribution
Beta Version February 2, 2001
2.7.4. Character
Constants
A character constant is a sequence of up to four characters enclosed in single
quotes (
'
). Characters that cannot be entered directly or conveniently into the
source program, such as nongraphic characters, can be specified in a character
constant using an escape sequence. Table 2.1 lists the available escape
sequences and their values.
Character constants have type int. The value of each character in a character
constant is its integer encoding in the ASCII character set or the value of its
associated escape sequence, whichever is applicable.
The double quote (
"
) and the question mark (
?
) can be specified directly or with
their escape sequences. The single quote (
'
) and the backslash (
\
) , however,
must be specified with their escape sequences.
In the octal and hexadecimal escape sequences,
ooo represents up to three
octal digits and
hhh represents up to three hexadecimal digits. These digit
sequences are terminated with the third digit or the first nonoctal (or
nonhexadecimal) character. The specified digits determine the value of the
character.
Escape Sequence Common Name Integer Value
\a alert (bell) 0x7
\b backspace 0x8
\f form feed 0xC
\n newline 0xA
\r carriage return 0xD
\t horizontal tab 0x9
\v vertical tab 0xB
\' single quote 0x27
\" double quote 0x22
\? question mark 0x3F
\\ backslash 0x5C
\
ooo
octal escape code
0
ooo (masked with 0xFF)
\x
hhh
hexadecimal escape code
0x
hhh (masked with 0xFF)
Table 2.1: Escape Characters
Some integer values that can be represented using three octal or hexadecimal
digits will not fit into a single eight-bit character. When a value does not fit into
eight bits, it is masked with the value 0xFF to force it to fit into eight bits. The
construct ' \x123 ' is a character constant containing a single character. To