in this code i'm comparing between two strings i did it correctly, but i don't want to consider the letters' case.
for ex: first string: aaaa, second string: aaaA. the output should be 0 or equal.
is there any ideas to fix this?
#include <iostream> #include <algorithm> #include <string> using namespace std; int main() { cout << "enter the first string" << endl; string x; cin >> x; cout << "enter the second string" << endl; string y; cin >> y; cout << endl; sort(x.begin(), x.end()); sort(y.begin(), y.end()); cout << x << endl; cout << y << endl; if (x.compare(y) < 0) { cout << "-1" << endl; } if (x.compare(y) > 0) { cout << "1" << endl; } if (x.compare(y) == 0) { cout << "0" << endl; } }
std::basic_string<char>, thanks.std::basic_string, it applies to every string type in every programming language. Admittedly C++ strings are even worse sincetolowerandtoupperare broken.