C++ - str(n)cmp(i) () 用于 C++ 样式字符串

标签 c++ string

<分区>

对于 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/

相关文章:

c++ - 将两个 Qt 选项卡向右移动,其余部分向左移动

javascript - 正则表达式为空

javascript - 使用 JSON.parse 将字符串(变量)转换为对象,错误意外标记

java - 使用 != 比较字符串

python 将字符串隐式转换为日期时间对象

c++ - 用于 Boost 数组的 SWIG/Lua 类型映射

c++ - std::map 有没有办法在 O(1) 时间内给出所有键 <= target_key 的计数器?

c++ - 编写插件系统?

c# - 如何打印字符串

C++,JSON,获取数组中的对象成员