isupper 函数是此编程语言中提供的标准库函数之一。C 语言的 isupper 函数用于检查给定的字符是否为大写字母。
下面此编程语言中的 isupper 函数将接受单个字符作为参数,并找出给定的字符是否为大写。
isupper(char)
isupper 是 <ctype.h> 头文件中存在的内置函数,用于检查字符是否为大写字母。C isupper 函数的语法是:
isupper (<character>);
isupper 函数将返回一个整数值作为输出。
- 如果 isupper 函数中的字符是大写的,它将返回一个非零值。
- 如果字符不是大写的,它将返回 0。
C 语言中的 isupper 示例
isupper 函数用于查找给定的字符是否为大写字符。这个 C 程序允许用户输入任何字符,并使用此函数检查字符是否在 A 到 Z 之间。
#include <stdio.h>
#include <ctype.h>
int main()
{
char ch;
printf("Please Enter Any Uppercase Character: \n");
scanf("%c", &ch);
if(isupper(ch))
{
printf("\n You have entered an Uppercase Character");
}
else
{
printf("\n %c is not an Uppercase Alphabet", ch);
printf("\n I request you to enter Valid Uppercase Character");
}
}

让我输入小写字母。
Please Enter Any Uppercase Character:
b
b is not an Uppercase Alphabet
I request you to enter Valid Uppercase Character
首先,我们声明了一个名为 ch 的字符变量。下面的 C 编程语句将要求用户输入任何字符。然后,我们使用 scanf 将用户输入的字符分配给 ch 变量。
printf("Please Enter Any Uppercase Character: \n");
scanf("%c", &ch);
接下来,我们使用 If 语句通过 C isupper 函数检查字符是否在 ‘A’ 和 ‘Z’ 之间。如果条件为 True,则将打印以下语句:
printf("\n You have entered an Uppercase Character");
如果上面的 If 语句为 FALSE,则给定的字符不是小写字母。因此,它将打印以下语句。
printf("\n %c is not an Uppercase Alphabet", ch);
printf("\n I request you to enter Valid Uppercase Character");
上面的代码将检查给定的字符是否为大写字符,但如果我们输入数字值会怎样?
Please Enter Any Uppercase Character:
7
7 is not an Uppercase Alphabet
I request you to enter Valid Uppercase Character
请参阅“C 程序检查字符是否为大写”文章。它帮助您了解如何在不使用 isupper 函数的情况下检查字符是否为大写字母。