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;
}
|
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
06 Jun, 2023
Like Article
Save Article