如果传递给 tolower() 函数的参数不是大写字母,它将返回传递给函数的相同字符。
它定义在 ctype.h 头文件中。
tolower() 的函数原型
int tolower(int argument);
在 C 编程中,字符以整数形式存储。当将字符作为参数传递时,会传递该字符对应的 ASCII 值(整数),而不是字符本身。
示例:tolower() 函数如何工作?
#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(+) = +