tolower() - Character Function

How is "tolower()" used in C++?

Explanation

tolower() function returns the lowercase of the parameter if its a letter, otherwise returns the same parameter without any change. It converts string to lowercase characters. The letter to convert may differ based on the locale settings, the default letters would be from a-z.

Syntax:


int tolower( int ch);

Example :



#include <iostream.h>
#include <ctype.h>
int main()
{
int n;
char c;
char str[]="ABCDEFGH123!";
cout << "String after using tolower is::";
for ( n=0 ; str[n]!='' ; n++)
{
c=str[n];
putchar (tolower(c));
}
return 0;
}

Result :

String after using tolower is::abcdefgh123

In the above example, "tolower()" function is used to convert the letter to lowercase characters, but the integers are displayed as it is.

C++ Tutorial


Ask Questions

Ask Question