C++ examples for STL:string
Compare two strings.
#include <iostream> #include <string> using namespace std; int main()/*w ww. j a v a 2s .c om*/ { string str1("Alpha"); string str2("Beta"); string str3("Gamma"); string str4; str4 = str1 + str3; cout << "Compare strings.\n"; if(str3 > str1) cout << "str3 > str1\n"; if(str3 == str1+str2) cout << "str3 == str1+str2\n"; if(str1 <= str2) cout << "str1 <= str2\n\n"; return 0; }