Total passenger exercises garlic: garlic king to learn English

   

Here it is mainly related to a string of case conversion function (in Curry's algorithm):

        transform(first, last, result, op);

first iterator is the first container, last iteration for the end of the vessel, result is the container for the result, op monohydric or sturct function object to be manipulated, class.

Specific use are as follows:

#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
 
using namespace std;
 
int main()
{
    string s = "Hello World";
    cout << s << endl;
    transform(s.begin(),s.end(),s.begin(),::toupper);//变大写
    cout << s << endl;
    transform(s.begin(),s.end(),s.begin(),::tolower);//变小写
   return 0; }

 

Guess you like

Origin www.cnblogs.com/Vikyanite/p/11740964.html