【C++】字符串不区分大小写比较

时间:2025-03-03 14:24:45
#include <> using namespace std; void main() { string str1 = "STR"; string str2 = "str"; if (0 == _stricmp(str1.c_str(), str2.c_str())) { cout << "str1 = str2" << endl; } else (0 > _stricmp(str1.c_str(), str2.c_str())) { cout << "str1 < str2" << endl; } else (0 < _stricmp(str1.c_str(), str2.c_str())) { cout << "str1 > str2" << endl; } }