简单类型 / 字符串

#include <iostream>
using namespace std;

string str = "Lower and upper";

string lower = str; 
transform(lower.begin(), lower.end(),
    lower.begin(), ::tolower);
//lower is "lower and upper"

string upper = str;
//Short solution using C++11
for (auto &c: upper) c = toupper(c);
//upper is "LOWER and UPPER"

cout << "lower is " << lower << endl;
cout << "upper is " << upper;