toupper c++ code example
Example 1: c++ char to uppercase
char choice;
choice = (char)toupper(choice);
Example 2: convert all characters in string to uppercase c++
transform(str.begin(), str.end(), str.begin(), ::toupper);
Example 3: string to upper c++
std::string data = "This is a sample string.";
std::for_each(data.begin(), data.end(), [](char & c){
c = ::toupper(c);
});
Example 4: toupper c++
int result = toupper(charecterVariable);
char result2 = (char)toupper(variableChar);
Example 5: c++ toupper string
#include <iostream>
#include <string>
#include <locale>
int main ()
{
std::locale loc;
std::string str="Test String.\n";
for (std::string::size_type i=0; i<str.length(); ++i)
std::cout << std::toupper(str[i],loc);
return 0;
}
Example 6: 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;
}