c_cpp 不区分大小写的字符串比较

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 不区分大小写的字符串比较相关的知识,希望对你有一定的参考价值。

// Case-insensitive string comparison
inline bool iequal(char c1, char c2) { return std::toupper(c1) == std::toupper(c2); }
bool iequals(const std::string& str1, const std::string& str2) {
  return  ((str1.size() == str2.size()) && std::equal(str1.begin(), str1.end(), str2.begin(), iequal));
}

以上是关于c_cpp 不区分大小写的字符串比较的主要内容,如果未能解决你的问题,请参考以下文章