代码点读机 / C / toupper

toupper C · 字符判断

把小写字母转换成大写;非小写字符保持不变。

怎么用

int c = toupper(字符);

小例子

#include <stdio.h>
#include <ctype.h>
int main(void) {
    printf("%c", toupper('a'));
    return 0;
}

运行结果

输出 A

提醒:返回值是 int,打印字符时要转成 char

官方文档:https://en.cppreference.com/w/c/string/byte/toupper

在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← C全部词条