开发者

c++ toupper - standard function? [duplicate]

开发者 https://www.devze.com 2023-01-25 18:48 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: Convert a String In C++ 开发者_如何学CTo Upper Case
This question already has answers here: Closed 12 years ago.

Possible Duplicate:

Convert a String In C++ 开发者_如何学CTo Upper Case

Hi, I need a portable function to convert string in c++ to upper case. I'm now using toupper( char); function. Is it a standard function? If not, what it's the correct way to do it across platforms? Btw, is there any web / wiki where I can list all c++ standard functions? Thank you.


Yes, toupper is declared in the cctype header. You can transform a string with an algorithm:

#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';
}


For the latter question, there's http://www.cplusplus.com/.


Hi in our project we use boost/algorithm/string to_upper function project for windows and linux

0

精彩评论

暂无评论...
验证码 换一张
取 消