C tolower()

如果传递给 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(+) = +
你觉得这篇文章有帮助吗?

我们的高级学习平台,凭借十多年的经验和数千条反馈创建。

以前所未有的方式学习和提高您的编程技能。

试用 Programiz PRO
  • 交互式课程
  • 证书
  • AI 帮助
  • 2000+ 挑战