+ Reply to Thread
Results 1 to 2 of 2

Thread: How to make Lower case string to upper case in C++?

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    29

    How to make Lower case string to upper case in C++?

    How to make Lower case string to upper case in C++?

  2. #2
    Senior Member
    Join Date
    Feb 2012
    Posts
    109
    Hi,

    You can use std::transform function to do this.

    Code:
    #include <string>
    #include <algorithm>
    
    void ConvertLowerCaseToUpperCase(std::string &strInputAndOutput)
    {
    	std::transform(strInputAndOutput.begin(), strInputAndOutput.end(), strInputAndOutput.begin(), toupper) ;
    }
    
    void UseLowerToUpperCase()
    {
    	std::string strSoccer = "i love soccer a lot!!!" ;
    
    	ConvertLowerCaseToUpperCase(strSoccer) ;
    }
    std::transform takes source start and end iterator, destination start position and a function to get execute for each item of the source container.

    Thanks.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

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