tolower()函数将大写字母转换为小写字符。
如果传递给tolower()函数的参数不是大写字母,则它返回传递给该函数的相同字符。
它在ctype.h 头文件中定义。
int tolower(int argument);
在C编程中,字符以整数形式存储。当字符作为参数传递时,将传递该字符的相应ASCII值(整数),而不是该字符本身。
#include <stdio.h>
#include <ctype.h>
int main()
{
char c, result;
c = 'M';
result = tolower(c);
printf("tolower(%c) = %c\n", c, result);
c = 'm';
result = tolower(c);
printf("tolower(%c) = %c\n", c, result);
c = '+';
result = tolower(c);
printf("tolower(%c) = %c\n", c, result);
return 0;
}
输出结果
tolower(M) = m
tolower(m) = m
tolower(+) = +