CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2001
    Posts
    145

    string to upper case

    Gurus,
    Is there a function in gcc which would convert a STRING (std::string) to upper case?

    Thanks in Advance

  2. #2
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,725
    std::transform() should work. I have two versions
    of g++. On one it works, on another (older) it has
    a compiler error.

    Code:
    #include <iostream>
    #include <algorithm>
    #include <string>
    
    using namespace std;
    
    int main(int argc, char* argv[])
    {
    
        string str = "Hello World";
    
        transform(str.begin(),str.end(), str.begin() , toupper);
    
        cout << str << endl;
    
        return 0;
    }

  3. #3
    Join Date
    Jul 2002
    Location
    Don't Know, Don't Care
    Posts
    346
    if you can use the windows.h header, use
    Code:
    ToUpper(const char*);

    C G C F A D--Feel the Noise

    "When your life goes nowhere and leads back to me, doesn't that tell you something?"
    ~Gray Area Fury

  4. #4
    Join Date
    Jun 2001
    Posts
    145
    thanks

  5. #5
    Join Date
    Jul 2002
    Location
    Don't Know, Don't Care
    Posts
    346
    oops, i made a mistake...
    it's
    Code:
    CharUpper(const char*);

    C G C F A D--Feel the Noise

    "When your life goes nowhere and leads back to me, doesn't that tell you something?"
    ~Gray Area Fury

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured