As we use a simple string with printf, we can use any escape sequences to print control characters that are difficult to represent. These are special characters that do not represent their literal meaning when used inside a string; instead they represent something special that would otherwise be difficult to represent as such. Most of the escape sequences consist of at least two characters, the first of which is a backslash character \, which is used to escape or mark a special character.
The following table lists the special characters that form the escape sequences with special meanings inside printf:
Special character |
Description |
\n |
Newline |
\t |
Tab |
\v |
Vertical tab |
\b |
Backspace |
\r |
Carriage return |
\f |
Form feed |
\<any character> |
That character |
\' |
Single quotation |
... |