When you use alphabetic characters in your program
- The compiler considers them as numbers but converts each to its corresponding character following the ASCII list
Counting decimal values starting at 0, the first 32 characters actually do not display anything on the screen:
- They are called non-printing characters
- They are obtained from pressing Ctrl and an alphabetic letter or a symbol
The exception is that the 8th to 12th characters are used to control some of the characters
- They are called escape sequences
- To use one of these escape sequences, you include it preceded by a backslash; you can include both in single-quotes
For example, the \n
- Is used to ask the compiler to stop the line and start the remaining program to the next line; this is referred to Carriage Return – Line Feed
- The \n escape sequence could be used as follows (A-1):
Example of (A-1)
#include <iostream> using namespace std; int main() { cout << “Tokyo\nJapan\n”; return 0; }
Besides the \n escape sequence
- You can also use the endl keyword to move the cursor to the next line
Here is the list of escape sequences:
| Escape Sequence | Name | ASCII value | Description |
|
\a |
Bell (alert) | 007 | Makes a sound from the computer |
|
\b |
Backspace | 008 | Takes the cursor back |
|
\t |
Horizontal Tab | 009 | Takes the cursor to the next tab stop |
|
\n |
New line | 010 | Takes the cursor to the beginning of the next line |
|
\v |
Vertical Tab | 011 | Performs a vertical tab |
|
\f |
Form feed | 012 | |
|
\r |
Carriage return | 013 | Causes a carriage return |
|
\” |
Double Quote | 034 | Displays a quotation mark (“) |
|
\’ |
Apostrophe | 039 | Displays an apostrophe (’) |
|
\? |
Question mark | 063 | Displays a question mark |
|
\\ |
Backslash | 092 | Displays a backslash (\) |
|
\0 |
Null | 000 | Displays a null character |

Discussion
No comments for “Escape Sequences”