1

Possible Duplicate:
Convert a String In C++ To 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.

4

3 回答 3

4

是的,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';
}
于 2010-11-17T13:02:27.670 回答
1

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

于 2010-11-17T12:59:44.440 回答
0

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

于 2010-11-17T13:01:56.970 回答