convert any string to uppercase in c++ code example
Example 1: convert whole string to uppercase c++
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s = "Viet Nam";
transform(s.begin(), s.end(), s.begin(), ::toupper);
cout << s << endl;
return 0;
}
Example 2: touppercase c++
#include <cctype>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
char str[] = "John is from USA.";
cout << "The uppercase version of \"" << str << "\" is " << endl;
for (int i=0; i<strlen(str); i++)
putchar(toupper(str[i]));
return 0;
}