string to lower cpp code example
Example 1: string to upper c++
std::string data = "This is a sample string.";
// convert string to upper case
std::for_each(data.begin(), data.end(), [](char & c){
c = ::toupper(c);
});
Example 2: tolower in c++
#include <cctype>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
char str[] = "John is from USA.";
cout << "The lowercase version of \"" << str << "\" is " << endl;
for (int i=0; i<strlen(str); i++)
putchar(tolower(str[i]));
return 0;
}