The problem is that in the line
transform( ...., tolower() );
You are calling the function tolower rather than passing it by reference to the transform algo.. -- drop the parenthesis ()
in the tolower...
The following is the text book examples....
#include <iostream> // std::cout
#include <algorithm> // std::transform
#include <vector> // std::vector
#include <functional> // std::plus
int main () {
std::string myname("my name IS soren");
// To upper
std::transform (myname.begin(), myname.end(), myname.begin(), ::toupper);
std::cout << myname << std::endl;
// To lower
std::transform (myname.begin(), myname.end(), myname.begin(), ::tolower);
std::cout << myname << std::endl;
// Capitalize first
std::transform (myname.begin(), myname.begin()+1, myname.begin(), ::toupper);
std::transform (myname.begin()+1, myname.end(), myname.begin()+1,::tolower);
std::cout << myname << std::endl;
return 0;
}
However as other have pointed out, this does not handle multi-byte (e.g. UTF-8) characters