CPP/Strings/Case Conversion
From ProgrammingExamples
< CPP
#include <string> #include <algorithm> // transform #include <functional> // ptr_fun #include <cctype> // toupper, tolower #include <iostream> int main() { std::string clive = "Clive Cherishes Capitals", lewis = "Lewis LOVES Lowercase"; // transform each character in 'clive' with 'toupper' std::transform(clive.begin(), clive.end(), clive.begin(), std::ptr_fun<int,int>(std::toupper) ); // transform each character in 'lewis' with 'tolower' std::transform(lewis.begin(), lewis.end(), lewis.begin(), std::ptr_fun<int,int>(std::tolower) ); std::cout << clive << std::endl; std::cout << lewis << std::endl; }