isupper() - C函數
C庫函數int isupper(int c) 檢查傳遞的字符是否是大寫字母。
聲明
以下是isupper()函數的聲明。
int isupper(int c);
參數
-
c -- 這是要檢查的字符。
返回值
這個函數返回一個非零值(true)如果c是大寫字母,否則為零(false)
例子
下麵的例子顯示isupper()函數的用法。
#include <stdio.h> #include <ctype.h> int main() { int var1 = 'M'; int var2 = 'm'; int var3 = '3'; if( isupper(var1) ) { printf("var1 = |%c| is uppercase character ", var1 ); } else { printf("var1 = |%c| is not uppercase character ", var1 ); } if( isupper(var2) ) { printf("var2 = |%c| is uppercase character ", var2 ); } else { printf("var2 = |%c| is not uppercase character ", var2 ); } if( isupper(var3) ) { printf("var3 = |%c| is uppercase character ", var3 ); } else { printf("var3 = |%c| is not uppercase character ", var3 ); } return(0); }
讓我們編譯和運行上麵的程序,這將產生以下結果:
var1 = |M| is uppercase character var2 = |m| is not uppercase character var3 = |3| is not uppercase character