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.

Community
  • 1
  • 1
kangcz
  • 165
  • 2
  • 8

3 Answers3

4

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';
}
Sebastian Mach
  • 37,451
  • 6
  • 88
  • 128
fredoverflow
  • 246,999
  • 92
  • 370
  • 646
1

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

Kos
  • 67,875
  • 23
  • 165
  • 229
0

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

Sanja Melnichuk
  • 3,465
  • 3
  • 24
  • 46