C++;-str(n)cmp(i)表示C++;样式字符串 C++的样式字符串的函数(代码)>代码/ > >代码> > STRNCPP()/和 STRCMCIP()/

C++;-str(n)cmp(i)表示C++;样式字符串 C++的样式字符串的函数(代码)>代码/ > >代码> > STRNCPP()/和 STRCMCIP()/,c++,string,C++,String,请不要建议使用strcmpi(str1.c_str,str2.c_str)等 提前感谢您的帮助。如果您使用的是Boost,您可以使用它进行不区分大小写的比较: #include <boost/algorithm/string.hpp> std::string str1 = "hello, world!"; std::string str2 = "hELLO, World!"; if (boost::iequals(str1, str2)) { // Strings are

请不要建议使用strcmpi(str1.c_str,str2.c_str)等


提前感谢您的帮助。

如果您使用的是Boost,您可以使用它进行不区分大小写的比较:

#include <boost/algorithm/string.hpp>

std::string str1 = "hello, world!";
std::string str2 = "hELLO, World!";

if (boost::iequals(str1, str2))
{
    // Strings are identical
}
#包括
std::string str1=“你好,世界!”;
std::string str2=“你好,世界!”;
if(boost::iequals(str1、str2))
{
//字符串是相同的
}

查看std::string.compareRelevant: