All pastes #899561 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-02-11 06:27 UTC
rendered paste body
// char and wchar_t types

#include <string>

#include <iostream>

using namespace std;

 

int main( )

{

    const basic_string <char> str1("TEST");

    // uses the typedef for string word synonym to basic_string <char>

    string str2("TEST");

    // simple comparison between two objects of type basic_string

    cout<<"String str1: "<<str1<<"\nString str2: "<<str2<<endl;

    cout<<"Operation: (str1 == str2)"<<endl;

    if(str1 == str2)

       cout<<"Strings str1 & str2 are equal."<<endl;

    else

       cout<<"Strings str1 & str2 are not equal."<<endl;

    // L - literal qualifier, long

    const basic_string <wchar_t> str3(L"TESTING");

    // uses the typedef for wstring word synonym to basic_string <wchar_t>

    wstring str4(L"JUMPING");

    // simple comparison between two objects of type basic_string <wchar_t>

    cout<<"\nString str3: TESTING \nString str4: JUMPING"<<endl;

    cout<<"Operation: (str3 == str4)"<<endl;

    if(str3 == str4)

       cout<<"Strings str3 & str4 are equal."<<endl;

    else

       cout<<"Strings str3 & str4 are not equal."<<endl;

    return 0;

}