#include#include using namespace std; int main() { TString str1= "apple"; TString str2= "orange"; int result = str1.CompareTo(str2); if(result == 0) { cout << "Both strings are equal" << endl; } else if(result < 0) { cout << "str1 comes before str2 in lexicographic order" << endl; } else { cout << "str2 comes before str1 in lexicographic order" << endl; } return 0; }
#includeThis code creates two strings, "apple" and "ApPlE", and ignores their case while comparing them using the CompareTo function. The program outputs "Both strings are equal". This example also uses the C++ root package library.#include using namespace std; int main() { TString str1= "apple"; TString str2= "ApPlE"; int result = str1.CompareTo(str2, TString::ECaseCompare::kIgnoreCase); if(result == 0) { cout << "Both strings are equal" << endl; } else if(result < 0) { cout << "str1 comes before str2 in lexicographic order" << endl; } else { cout << "str2 comes before str1 in lexicographic order" << endl; } return 0; }