Escape sequences are used to represent certain special characters within string literals and character constants.
The following escape sequences are available. ISO C requires a diagnostic if the backslash is followed by any character not listed here:
| Escape sequence | Description | Representation | 
|---|---|---|
| Simple escape sequences | ||
| \' | single quote | byte 0x27in ASCII encoding | 
| \" | double quote | byte 0x22in ASCII encoding | 
| \? | question mark | byte 0x3fin ASCII encoding | 
| \\ | backslash | byte 0x5cin ASCII encoding | 
| \a | audible bell | byte 0x07in ASCII encoding | 
| \b | backspace | byte 0x08in ASCII encoding | 
| \f | form feed - new page | byte 0x0cin ASCII encoding | 
| \n | line feed - new line | byte 0x0ain ASCII encoding | 
| \r | carriage return | byte 0x0din ASCII encoding | 
| \t | horizontal tab | byte 0x09in ASCII encoding | 
| \v | vertical tab | byte 0x0bin ASCII encoding | 
| Numeric escape sequences | ||
| \nnn | arbitrary octal value | code unit nnn | 
| \xn... | arbitrary hexadecimal value | code unit n...(arbitrary number of hexadecimal digits) | 
| Universal character names | ||
| \unnnn(since C99) | Unicode value in allowed range; may result in several code units | code point U+nnnn | 
| \Unnnnnnnn(since C99) | Unicode value in allowed range; may result in several code units | code point U+nnnnnnnn | 
| Range of universal character namesIf a universal character name corresponds to a code point that is not  | (since C99) | 
\0 is the most commonly used octal escape sequence, because it represents the terminating null character in null-terminated strings.
The new-line character \n has special meaning when used in text mode I/O: it is converted to the OS-specific newline byte or byte sequence.
Octal escape sequences have a length limit of three octal digits but terminate at the first character that is not a valid octal digit if encountered sooner.
Hexadecimal escape sequences have no length limit and terminate at the first character that is not a valid hexadecimal digit. If the value represented by a single hexadecimal escape sequence does not fit the range of values represented by the character type used in this string literal or character constant (char, char8_t(since C23), char16_t, char32_t(since C11), or wchar_t), the result is unspecified.
| A universal character name in a narrow string literal or a 16-bit string literal(since C11) may map to more than one code unit, e.g.  | (since C99) | 
| A universal character name corresponding to a code pointer greater than  | (since C99) (until C23) | 
| The question mark escape sequence  | (until C23) | 
#include <stdio.h>
 
int main(void)
{
    printf("This\nis\na\ntest\n\nShe said, \"How are you?\"\n");
}Output:
This is a test She said, "How are you?"
| C++ documentation for Escape sequences | 
    © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
    https://en.cppreference.com/w/c/language/escape