C++ <cctype> - tolower() Function
The C++ <cctype> tolower() function is used to convert the given character to lowercase according to the character conversion rules defined by the currently installed C locale.
In the default "C" locale, the following uppercase letters ABCDEFGHIJKLMNOPQRSTUVWXYZ are replaced with respective lowercase letters abcdefghijklmnopqrstuvwxyz.
Syntax
int tolower ( int ch );
Parameters
ch |
Specify the character to be converted, casted to an int, or EOF. |
Return Value
Returns lowercase version of ch or unchanged ch if no lowercase value is listed in the current C locale.
Example:
The example below shows the usage of tolower() function.
#include <iostream> #include <cctype> using namespace std; int main (){ char str[50] = "HELLO World!"; //converting str into lower case int i = 0; while(str[i]) { str[i] = tolower(str[i]); i++; } //displaying the output cout<<str<<"\n"; return 0; }
The output of the above code will be:
hello world!
❮ C++ <cctype> Library