<分区>
对于 C++ 样式字符串,函数 strcmpi()
、strncmp()
和 strncmpi()
的等价物是什么?
请不要建议使用 strcmpi(str1.c_str, str2.c_str)
等
在此先感谢您的帮助。
<分区>
对于 C++ 样式字符串,函数 strcmpi()
、strncmp()
和 strncmpi()
的等价物是什么?
请不要建议使用 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
}
关于C++ - str(n)cmp(i) () 用于 C++ 样式字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17045159/