C++ cctype tolower() Function
Example
Convert a character to lowercase:
char upper = 'A';
char lower = tolower(upper);
cout << upper << " in lowercase is " << lower;
Definition and Usage
The tolower() function returns the lowercase version of a character. If the character is not an uppercase letter, like '5' or '!', it is returned without any change.
The function returns an int, so store the result in a char, like in the example. If you print the result directly, cout << tolower('A') prints 97 (the ASCII value of a), not a.
The tolower function is defined in the <cctype> header file.
Tip: See how tolower() is used in How To Count Vowels in a String.
Syntax
int tolower(int c);
Parameter Values
| Parameter | Description |
|---|---|
| c | Required. The character to convert. |
Technical Details
| Returns: | An int with the lowercase version of the character. If the character is not an uppercase letter, it is returned unchanged. |
|---|
Related Pages
Read more about strings in our Strings Tutorial.