I want to convert a std::string to lowercase. I am aware of the function tolower(), however in the past I have had issues with this function and it
std::string
tolower()
I wrote this simple helper function:
#include // tolower string to_lower(string s) { for(char &c : s) c = tolower(c); return s; }
Usage:
string s = "TEST"; cout << to_lower("HELLO WORLD"); // output: "hello word" cout << to_lower(s); // won't change the original variable.