Home   |   About   |   Terms   |   Contact    
A platform for writers

What is Escape Sequence in C++?


☯ All C++ Articles     ☯ All Articles

Popular Google Pages:

◕ Send your story to RiyaButu.com and get ₹ 500/- Details..

◕ Bengali Story writing competition. Details..

◕ 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.

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
cout << "We are Indian \n";

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

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

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

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

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

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

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

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

■ Double quote \"
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++

Top of the page

Amazon & Flipkart Special Products


Top of the page