/*************************************************/ // escapeSequences.cpp // R. A. Hillyard // Last Modified: 02/05/2001 // // Demonstrates the use of escapeSequences // in string literals /*************************************************/ #include <iostream>
using namespace std; int main( void ) { cout << "In C++ anything between the \"\" marks is a string constant\n" ; cout << "\nTo include special characters in a string constant " ; cout << "we use an \"escape sequence\"" << endl << endl; cout << "The \\ will change the meaning of the character following it\n\n" ; cout << "\\n will give you a new line just like cout << endl\n"; cout << "\nand\n\n" ; cout << "\\t will give you a tab\t\t\tof the default value\n\n" ; cout << "you also need to escape the double \" and single \' quotes\n" ; return 0; } /*****************************************************************/ In C++ anything between the "" marks is a string constant To include special characters in a string constant we use an "escape sequence" The \ will change the meaning of the character following it \n will give you a new line just like cout << endl and \t will give you a tab of the default value you also need to escape the double " and single ' quotes