
- C 標準庫
- C 庫 - 首頁
- C 庫 - <assert.h>
- C 庫 - <complex.h>
- C 庫 - <ctype.h>
- C 庫 - <errno.h>
- C 庫 - <fenv.h>
- C 庫 - <float.h>
- C 庫 - <inttypes.h>
- C 庫 - <iso646.h>
- C 庫 - <limits.h>
- C 庫 - <locale.h>
- C 庫 - <math.h>
- C 庫 - <setjmp.h>
- C 庫 - <signal.h>
- C 庫 - <stdalign.h>
- C 庫 - <stdarg.h>
- C 庫 - <stdbool.h>
- C 庫 - <stddef.h>
- C 庫 - <stdio.h>
- C 庫 - <stdlib.h>
- C 庫 - <string.h>
- C 庫 - <tgmath.h>
- C 庫 - <time.h>
- C 庫 - <wctype.h>
- C 標準庫資源
- C 庫 - 快速指南
- C 庫 - 有用資源
- C 庫 - 討論
- C 程式設計資源
- C 程式設計 - 教程
- C - 有用資源
C 庫 - iswupper() 函式
C 的wctype庫的iswupper()函式用於檢查給定的寬字元(由wint_t表示)是否為大寫字母,即“ABCDEFGHIJKLMNOPQRSTUVWXYZ”中的一個或當前區域設定特有的任何大寫字母。
此函式可用於字元驗證、大小寫轉換、字串處理或標記化和解析。
語法
以下是iswupper()函式的C庫語法:
int iswupper( wint_t ch )
引數
此函式接受一個引數:
-
ch - 它是要檢查的型別為'wint_t'的寬字元。
返回值
如果寬字元是大寫字母,則此函式返回非零值,否則返回零。
示例 1
以下是用C語言編寫的基本示例,演示了iswupper()函式的使用。
#include <stdio.h> #include <wctype.h> #include <wchar.h> int main() { wchar_t wc = L'A'; if (iswupper(wc)) { wprintf(L"The character '%lc' is a uppercase letter.\n", wc); } else { wprintf(L"The character '%lc' is not a uppercase letter.\n", wc); } return 0; }
輸出
以下是輸出:
The character 'A' is a uppercase letter.
示例 2
我們建立一個C程式,並使用iswupper()來計算給定寬字元中大寫字母的數量。
#include <stdio.h> #include <wctype.h> #include <wchar.h> int main() { // Define a wide string with mixed characters wchar_t str[] = L"Hello, tutorialspoint India"; int uppercaseCount = 0; // Iterate over each character in the wide string for (int i = 0; str[i] != L'\0'; i++) { if (iswupper(str[i])) { uppercaseCount++; } } // Print the result wprintf(L"The wide string \"%ls\" contains %d uppercase letter(s).\n", str, uppercaseCount); return 0; }
輸出
以下是輸出:
The wide string "Hello, tutorialspoint India" contains 2 uppercase letter(s).
示例 3
以下為另一個示例,當我們在給定的寬字元中獲得大寫字母時,我們列印大寫字母。
#include <stdio.h> #include <wctype.h> #include <wchar.h> int main() { wchar_t str[] = L"Hello, tutorialspoint India"; // Iterate over each character in the wide string for (int i = 0; str[i] != L'\0'; i++) { if (iswupper(str[i])) { wprintf(L"%lc", str[i]); } } return 0; }
輸出
以下是輸出:
HI
c_library_wctype_h.htm
廣告