I want to know
How to compare 2 CString?
is there something like strcmp(s1, s2)?
Thanks
I want to know
How to compare 2 CString?
is there something like strcmp(s1, s2)?
Thanks
I get it
s1 == s2
so simple
CString objects support comparison through the == operator as well as the Compare and CompareNoCase member functions (which return 0 if the strings are equal).
Code:// example for CString == Operators CString s1( "abc" ); CString s2( "abc" ); if( s1 == s2 ) cout << "They are the same." << endl; else cout << "They are different." << endl;Code:// example for CString::Compare CString s1( "abc" ); CString s2( "abc" ); if( !s1.Compare( s2 ) ) cout << "They are the same." << endl; else cout << "They are different." << endl;Code:// example for CString::CompareNoCase CString s1( "abc" ); CString s2( "ABC" ); if( !s1.CompareNoCase( s2 ) ) cout << "They are the same." << endl; else cout << "They are different." << endl;
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens