Escape sequences are typically used to specify actions such as carriage returns and tab movements on terminals and printers. They are also used to provide literal representations of nonprinting characters and characters that usually have special meanings, such as the double quotation mark ("). Table 1.4 lists the ANSI escape sequences and what they represent. Note that the question mark preceded by a backslash (\?) specifies a literal question mark in cases where the character sequence would be misinterpreted as a trigraph. See Trigraphs for more information. Table 1.4 Escape Sequences
| Escape Sequence | Represents |
|---|---|
| \a | Bell (alert) |
| \b | Backspace |
| \f | Formfeed |
| \n | New line |
| \r | Carriage return |
| \t | Horizontal tab |
| \v | Vertical tab |
| \' | Single quotation mark |
| \" | Double quotation mark |
| \\ | Backslash |
| \? | Literal question mark |
| \ooo | ASCII character in octal notation |
| \xhhh | ASCII character in hexadecimal notation |
If a backslash precedes a character that does not appear in Table 1.4, the compiler handles the undefined character as the character itself. For example, \x is treated as an x.
Escape sequences allow you to send nongraphic control characters to a display device. For example, the ESC character (\033) is often used as the first character of a control command for a terminal or printer. Some escape sequences are device-specific. For instance, the vertical-tab and formfeed escape sequences (\v and \f) do not affect screen output, but they do perform appropriate printer operations.