I would like to know how to do this. Are there any functions specifically for it? Or do you have to do it manually?

#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>

using namespace std;

int lower_case ( int c )
{
  return tolower ( c );
}

int main()
{
  string s = "THIS IS A TEST";

  transform ( s.begin(), s.end(), s.begin(), lower_case );
  cout<< s <<endl;
}

Before you ask, no, you can't safely pass tolower directly to transform in all situations. It's a subtle issue that not many people are aware of, but tolower is an overloaded function and transform is a template function. transform can't deduce which tolower you want, so it's a conflict. You could cast the third argument, but that's a dangerous solution.

..

#include <functional>
#include <cctype>
#include <string>
#include <algorithm>

//...
string s="ACBCD";
std::transform(s.begin(), s.end(), s.begin(), std::ptr_fun<int, int>(std::tolower));
commented: Don't bump old threads -1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.