Constant Escape Sequences [C++ Reference]
Keywords: escape_sequences
Date: 2009-07-19T12:21:51-0700

[[Constant Escape Sequences]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- fr
- it
- jp
- pl
- ru
- tr

## Constant Escape Sequences

The following escape sequences can be used to define certain special characters within strings:

Escape Sequence | Description
--- | ---
\' | Single quote
\” | Double quote
\\ | Backslash
\nnn | Octal number (nnn)
\0 | Null character (really just the octal number zero)
\a | Audible bell
\b | Backspace
\f | Formfeed
\n | Newline
\r | Carriage return
\t | Horizontal tab
\v | Vertical tab
\xnnn | Hexadecimal number (nnn)

An example of this is contained in the following code (which assumes that the newline character generates complete newlines, i.e. on Unix systems):

        printf( "This\nis\na\ntest\n\nShe said, \"How are you?\"\n" );

which would display

        This
        is
        a
        test

        She said, "How are you?"

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •