Home   |   About   |   Terms   |   Contact    
Read & Learn
 

What is Escape Sequence in C++?

C++

☯ All C++ Articles     ☯ All Articles


A new product.




Popular Google Pages:



◕ This article is regarding What is Escape Sequence in C++? & Complete list of Escape Sequence.
Last updated on: .



◕ What is Escape Sequence in C++ ?

- There are some characters that we can’t enter into a program directly from the keyboard.
For example, we can’t make a new line in a program by pressing the Enter Key.
For this, we have to write some code in our source code file.
Same as the double quotation mark. We can’t put a double quotation mark in the middle of a string.
Like:

cout << " He said, "I am an Indian." " << endl;

C++ will not run this code. Instead we have to use special notations, called Escape Sequence.

The correct code is:
cout << " He said, \"I am an Indian.\" " << endl;

This \" is called the Escape Sequence.





◕ The complete list of C++ Escape Sequence with example is given bellow:

■ Newline \n
Example:
cout << "We are Indian \n";

■ Horizontal tab \t
Example:
cout << "We are Indian \t";

■ Vertical tab \v
Example:
cout << "We are Indian \v";

■ Backspace \b
Example:
cout << "We are Indian\b";

■ Carriage return \r
Example:
cout << "We are Indian \r";

■ Alert \a
Example:
cout << "We are Indian \a";

■ Backslash \\
Example:
cout << "We are Indian \\";

■ Question mark \?
Example:
cout << "We are Indian \?";

■ Single quote \'
Example:
cout << "We are \'Indian\'";

■ Double quote \"
Example:
cout << "We are \" Indian \" ";





Related articles:
How to display a value in Hexadecimal form in C++?
How C++ identify the base of a number?
Symbolic Constant in C++




Popular Google Pages:



Top of the page

Amazon & Flipkart Special Products

   


Top of the page