Example of String Comparison
string strA = "hello";
string strB = "a";
if ( strA == "hello" )
cout << "got it" << endl;
if ( "hello" == strA )
cout << "got it again" << endl;
if ( strB != strA )
cout << "not equal works!" << endl;
if ( strA > "Hello" )
cout << "Caps are less" << endl;
// Direct comparison with chars is not allowed by Visual C++ 6.0
if ( strB == 'a' )
cout << "match with char" << endl;
// but the following will work
if ( strB == string(1,'a') )
cout << "match with char" << endl;
// The following automatically invokes string( const char s[] )
// to convert a C sting parameter to a C++ string then uses
// int compare( size_type pos1, size_type n1,
// const string& str, size_type pos2, size_type n2 ) const;
if ( strA.compare(1,2,"asdceled",4,2) == 0 )
cout << "another hit" << endl;