Join our newsletter for the latest updates.

C++ tolower()

The tolower() function in C++ converts a given character to lowercase.

tolower() Prototype

The function prototype of the tolower() function is

int tolower(int ch);

If the character passed to tolower() function is an alphabet, the function returns its corresponding lowercase character.


tolower() Parameters

ch - a character


tolower() Return value

The tolower() function returns the lowercase version of the character (if it's an alphabet). Otherwise, it returns the character itself.


It is defined in the <cctype> header file.


Example: tolower() function

#include <cctype>
#include <iostream>

using namespace std;

int main() {
  char c1 = 'A', c2 = 'b', c3 = '9';

  cout << (char) tolower(c1) << endl;  // a
  cout << (char) tolower(c2) << endl;  // b
  cout << (char) tolower(c3) << endl;  // 9

  return 0;
}

Output

a
b
9
Did you find this article helpful?