1std::string data = "This is a sample string.";
2// convert string to upper case
3std::for_each(data.begin(), data.end(), [](char & c){
4c = ::toupper(c);
5});
1#include <cctype>
2#include <iostream>
3#include <cstring>
4#include <cstdio>
5
6using namespace std;
7
8int main()
9{
10 char str[] = "John is from USA.";
11
12 cout << "The uppercase version of \"" << str << "\" is " << endl;
13
14 for (int i=0; i<strlen(str); i++)
15 putchar(toupper(str[i]));
16
17 return 0;
18}