Escape sequences in C are special characters used to represent non-printable or special characters within strings and character literals. They are denoted by a backslash \ followed by a specific character. In this tutorial, we will explore the commonly used escape sequences in C and their corresponding representations.
Here is a table of some common Escape Sequences used in C language:
Escape Sequence | Description | Representation |
---|---|---|
\\ | Backslash | \ |
\' | Single quote (apostrophe) | ' |
\" | Double quote | " |
\n | Newline character | (newline) |
\t | Horizontal tab | (tab) |
\r | Carriage return | (return) |
\b | Backspace | (backspace) |
\f | Form feed (page break) | (form feed) |
\v | Vertical tab | (vertical tab) |
\a | Alert (bell) | (alert) |
\0 | Null character | (null) |
Here is an example program that demonstrates the use of new lines and escape sequences in C language:
Output: