Escape sequences for special character printing
As we use a simple string with printf
, we can use any escape sequencesto print control charactersthat are difficult to represent.These are special characters that do not representtheir literal meaningwhen 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 backslashcharacter \
, 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 |
| Newline |
| Tab |
| Vertical tab |
| Backspace |
| Carriage return |
| Form feed |
| That character |
| Single quotation |
| Double quotation |
| Backslash character |
The following are a few more special characters:
- Horizontal tab: In the following example, we use
\t
to put a horizontal tab between the fields of the employee database...