Escape Sequences for Nonprintable Characters

Some characters are nonprintable. A nonprintable character is a character for which there is no visible image, such as backspace or a control character. Other characters have special meaning in the language, such as the single and double quotation marks, and the backslash. Nonprintable characters and special characters are written using an escape sequence. An escape sequence begins with a backslash. The language defines the following escape sequences:

newline \n horizontal tab \t
veritcal tab \v backspace \b
carriage return \r formfeed \f
alert (bell) \a backslash \\
question mark \? single quote \’

We can write any character as a generalized escape sequence of the form
where ooo represents a sequence of as many as three octal digits. The value of the octal digits represents the numerical value of the character. The following examples are representations of literal constants using the ASCII character set:

\7 (bell)
\12 (newline)
\40 (blank)
\0 (null)
\062 (‘2’)
\115 (‘M’)

The character represented by ‘\0’ is often called a “null character,” and has special significance, as we shall soon see.
We can also write a character using a hexadecimal escape sequence
consisting of a backslash, an x, and one or more hexadecimal digits


You may also like...