C++ examples for Data Type:char
Escape Sequence | Control Character |
---|---|
\n | Newline |
\t | Horizontal tab |
\v | Vertical tab |
\b | Backspace |
\r | Carriage return |
\f | Form feed |
\a | Alert/bell |
\\ | Backslash |
\' | Single quote |
\" | Double quote |
\? | Question mark |
Because the backslash signals the start of an escape sequence, to enter a backslash, use two successive backslashes \\.
The following code that uses escape sequences outputs a message to the screen.
#include <iostream> int main()//from w w w . ja v a2 s . co m { std::cout << "\"Least \'said\' \\\n\t\tsoonest \'mended\'.\"" << std::endl; }