Archive for August, 2007

C++ — Convert string to upper/lower case

August 4, 2007

To convert an std::string to upper case you can use the following:

#include <algorithm>
#include <string>

std::string data = “Abc”;
std::transform(data.begin(), data.end(),
data.begin(), ::toupper);

For converting to lower case, you need to replace ::toupper with ::tolower.