Char Escapes : string « String « C++






Char Escapes

  
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string y1( "a\x62" );
    cout << y1 << endl;   // y1 is string "ab".
                                                      
    string y6( "a\xef" );
    cout << y6 << endl;                               
                                                      
    string w1( "a\142" );
    cout << w1 << endl;                               
                                                      
    string w2( "a\142c" );
    cout << w2 << endl;                               
                                                      
    string w3( "a\142142" );
    cout << w3 << endl;                               
                                                      
    string w4( "a\79" );
    cout << w4 << endl;                               
                                                      
    string w5( "\x00007p\x0007q\x0007r\x007s\x07t\x7u" );
    
    cout << w5 << endl; 

    return 0;
}
  
    
  








Related examples in the same category

1.Define a string variable, assign a value and display it
2.string basics
3.copy constructor
4.Changing Case in Strings
5.A short string demonstration.A short string demonstration.
6.Extracting Words in Strings Delimited by Whitespace
7.Loop through the string array