tolower() function in C is used to convert the uppercase alphabet to the lowercase alphabet. It does not affect characters other than uppercase characters. It is defined in the <ctype.h> header file in C.
Syntax
The syntax of tolower() function is:
int tolower(int c);
Parameter
- This function takes a character as a parameter.
Return Value
- It returns the ASCII value corresponding to the lowercase of the character passed as the argument.
Examples of tolower() Function
Example 1
The below C program demonstrates the tolower() function.
C
#include <ctype.h>
#include <stdio.h>
int main()
{
char ch = tolower ( 'M' );
printf ( "%c" , ch);
return 0;
}
|
Example 2
The below code converts all uppercase letters in the string to their lowercase equivalents, while leaving other characters unchanged.
C
#include <ctype.h>
#include <stdio.h>
int main()
{
char s[] = "Code_in_C_@0123" ;
for ( int i = 0; i < strlen (s); i++) {
s[i] = tolower (s[i]);
}
printf ( "%s" , s);
return 0;
}
|
Last Updated :
06 Jun, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...