c++ 忽略大小写字符串比较函数

时间:2023-01-16 00:52:42

#include "iostream"
#include "string"

bool stringCompareIgnoreCase(std::string lhs,std::string rhs)
{
 return _stricmp(lhs.c_str(),rhs.c_str());
}

int main()
{
 std::cout << " hello " << std::endl;
 std::string string1 = "HELLO";
 std::string string2 = "Hel0";

 bool aa =stringCompareIgnoreCase(std::string(string1,0,4),std::string(string2,0,4));
 std::cout << "aa =" << aa << std::endl;
 std::cout << std::string(string1,0,4) << std::endl;
 std::cout << std::string(string2,0,4) << std::endl;
 system("pause");
 return 1;
}