【问题标题】:c++ toupper - standard function? [duplicate]c++ toupper - 标准函数? [复制]
【发布时间】:2011-05-11 09:51:51
【问题描述】:

可能重复:
Convert a String In C++ To Upper Case

嗨, 我需要一个可移植的函数来将 C++ 中的字符串转换为大写。我现在正在使用 toupper(char);功能。它是标准功能吗?如果不是,那么跨平台执行此操作的正确方法是什么?顺便说一句,有没有可以列出所有 C++ 标准函数的网络/维基?谢谢。

【问题讨论】:

    标签: c++ cross-platform standard-library c++-standard-library


    【解决方案1】:

    对于后一个问题,有http://www.cplusplus.com/

    【讨论】:

      【解决方案2】:

      您好,在我们的项目中,我们在 windows 和 linux 中使用 boost/algorithm/string to_upper 函数项目

      【讨论】:

        【解决方案3】:

        是的,touppercctype 标头中声明。您可以使用算法转换字符串:

        #include <algorithm>
        #include <iostream>
        #include <string>
        #include <cctype>
        
        int main()
        {
            std::string str("hello there");
            std::cout << str << '\n';
        
            std::transform(str.begin(), str.end(), str.begin(), std::toupper);
            std::cout << str << '\n';
        }
        

        【讨论】:

        • 你需要范围解析操作符
        • 有什么建议什么时候用toupper(char),什么时候用toupper(char, locale)?
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-04-26
        • 2022-01-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-08
        相关资源
        最近更新 更多