C isupper()

C isupper() 声明

int isupper(int argument);

isupper() 函数接受一个整数参数,并返回一个 `int` 类型的值。

尽管 isupper() 接受整数作为参数,但传递给函数的是字符。在内部,该字符会被转换为其 ASCII 值进行检查。

它定义在 `<ctype.h>` 头文件中。


C isupper() 的返回值

返回值 备注
非零整数 ( x > 0 ) 参数是大写字母。
零 (0) 参数不是大写字母。

示例:C isupper() 函数

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

    c = 'C';
    printf("Return value when uppercase character %c is passed to isupper(): %d", c, isupper(c));

    c = '+';
    printf("\nReturn value when another character %c is passed to is isupper(): %d", c, isupper(c));

   return 0;
}

输出

Return value when uppercase character C is passed to isupper(): 1
Return value when another character + is passed to is isupper(): 0

注意: 在您的系统上,当传递大写字母给 isupper() 时,您可能会得到不同的整数值。但是,当您向 isupper() 传递任何非大写字母时,它总是返回 0。

你觉得这篇文章有帮助吗?

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

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

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