Is there an inbuilt function to convert C++ string from upper case letters to lowercase letters ? If not converting it to cstring and using tolower on each char is the only option ?
Thank you very much in advance.
If boost
is an option:
#include <boost/algorithm/string.hpp>
std::string str = "wHatEver";
boost::to_lower(str);
Otherwise, you may use std::transform
:
std::string str = "wHatEver";
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
You can also use another function if you have some custom locale-aware tolower
.