C++ String case conversion and transform, tower, upper, usage

String case conversion is not provided in C++, but as I wrote today, there are many ways to do it.
Of course, you could have s[I]+32 or s[I]-32

#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);//<span style="font-family:'Times New Roman';">::toupper</span>to<span style="font-family:'Times New Roman';">upp<span style="font-family:'Times New Roman';">er</span></span>
    cout << s << endl;
    transform(s.begin(),s.end(),s.begin(),::tolower);//<font face="'Times New Roman'">::t<span style="font-family:'Times New Roman';">olo<span style="font-family:'Times New Roman';">wer<span style="font-family:'Times New Roman';">使用</span></span></span></font><span style="font-family:'Times New Roman';"></span>to<span style="font-family:'Times New Roman';">lower</span>
    cout << s << endl;
    return 0;
}

Toupper and tolower are defined in C++ in STD and cctype, respectively

When defined in STD, the prototype is charT Toupper (charT C, Const Locale& loc);
While the transform function:
Applies an operation to each element of the specified scope.
The Transform function has two overloaded versions:

transform(first,last,result,op); // First is the first iterator of the container, last is the last iterator of the container, result is the container that holds the result, op is the unary function object or STURct, class to be operated on.

transform(first1,last1,first2,result,binary_op); // First1 is the first iterator of the first container, last1 is the last iterator of the first container, first2 is the first iterator of the second container, result is the container that holds the result, and binary_OP is the binary function object or STURct, class to be operated on
As above, the STD of toupper prototype as a binary function, so the use of STD: : toupper complains: unresolved overloaded function
But you can use it this way:

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    string s = "Hello World";
    cout << s << endl;
    transform(s.begin(),s.end(),s.begin(),(int (*)(int))toupper);
    cout << s << endl;
    transform(s.begin(),s.end(),s.begin(),(int (*)(int))tolower);
    cout << s << endl;
    return 0;
}

Function pointer resolves


Read More: