C toupper()

toupper() 函数的原型是:

int toupper(int ch);

toupper() 参数

该函数接受一个参数。

  • ch - 一个字符

toupper() 的返回值

如果传递给 toupper() 的参数是

  • 一个小写字母,则函数返回其对应的大写字母
  • 一个大写字母或一个非字母字符,则函数返回该字符本身

toupper() 函数定义在 <ctype.h> 头文件中。


示例:C toupper() 函数

#include <stdio.h>
#include <ctype.h>
int main() {
    char c;

    c = 'm';
    printf("%c -> %c", c, toupper(c));

    c = 'D';
    printf("\n%c -> %c", c, toupper(c));

    c = '9';
    printf("\n%c -> %c", c, toupper(c));
    return 0;
}

输出

m -> M
D -> D
9 -> 9
你觉得这篇文章有帮助吗?

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

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

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