Digraph, Trigraph, and Escape Sequences

Digraph Sequence

You can represent unavailable characters in a source program by using a combination of two keystrokes called a digraph sequence. Digraphs are read as tokens during the preprocessor phase. Digraphs can be created using macro concatenation. They are not replaced in string literals or in character literals.

The following table is a list of the digraphs that were supported in previous compilers.

Digraph Sequence
<% { left brace
%> } right brace
<: [ left bracket
:> ] right bracket
%: # pound sign
%:%: ## preprocessor macro concatenation operator

Trigraph Sequences
Some characters from the C character set are not available in all environments. You can enter these characters into a C source program using a sequence of three characters called a trigraph. The trigraph sequence are:

Trigraph Sequence
??= # pound sign
??( [ left bracket
??) ] right bracket
??< { left brace
??> } right brace
??/ \ backslash
??' ^ caret
??! | pipe
??- ~ tilde

The preprocessor replaces trigraph sequence with the corresponding single-character representation.

Escape Sequence
An escape sequence contains a backslash (\) symbol followed by one of the escape sequence characters or an octal or hexadecimal number. A hexadecimal escape sequence contains an x followed by one or more hexadecimal digits (0-9, A-F, a-f). An octal escape sequence uses up to three octal digits (0-7).

Note: The line continuation sequence (\ followed by a new line character) is not an escape sequence. It is used in character strings to indicate that the current line continues on the next line.

Escape Sequence Character Represented
\a Alert (bell, alarm)
\b Backspace
\f Form feed (new page)
\n New-line
\r Carriage return
\t Horizontal tab
\v Vertical tab
\' Single quotation mark
\" Double quotation mark
\? Question mark
\\ Backslash
\ooo Octal number
\hhh Hex number