C++字符串操作小结

忽略大小写比较大小

  • 库函数strcasecmp和_stricmp:
    这两个函数都不属于C++标准库,strcasecmp由POSIX引入,windows平台则定义了功能等价的_stricmp。用法和C++标准库的strcmp类似。

    #include <cstring>
    
    #if defined(_WIN32)
    #define strcasecmp _stricmp
    #endif
    
  • boost函数iequals:

    #include <boost/algorithm/string.hpp>
    
    int main(int argc, const char *argv[]) {
        bool equal = boost::iequals("ABC", "abc");
        return 0;
    }
    

猜你喜欢

转载自www.cnblogs.com/HachikoT/p/12561204.html