Escape sequences:
- you can also use '\n', which denotes a newline character, to advance the cursor to the next line.
- Similarly, you could use '\t', which denote a tab character, to advance the cursor to the next tab position.
- ‘\a’ this escape sequence is used to play beep during execution.
- '\b' Whenever we want to delete a single character, we press the button “backspace” from our keyboard. The same functionality can be achieved in C++ output with this escape sequence.
- \’ To insert a single quote in the output, this escape sequence is used.
- \” To insert a double quote in the output, this escape sequence is used.
Escape sequences examples:
cout << "hello world, again!\n";
cout << "\thello, ";
Output:
Use of Escape Sequences \n, \t with example in C++ programming Language |
cout<<”Hello\aWorld”;
First of all, “Hello” is printed then a beep is played and after that “World” is printed.
cout<<”Hello\bWorld”;
Output: HellWorld
cout<<”\’Hello World\’”;
Output: 'Hello World'
0 Comments