- 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 庫 - iswlower() 函式
C 的wctype庫 iswlower() 函式用於檢查給定的寬字元(由 wint_t 表示)是否為小寫字母,即“abcdefghijklmnopqrstuvwxyz”中的一個,或當前區域設定特有的任何小寫字母。
此函式可用於字元驗證、大小寫轉換、字串處理或標記化和解析。
語法
以下是 iswlower() 函式的 C 庫語法:
int iswlower( wint_t ch )
引數
此函式接受一個引數:
-
ch − 一個待檢查的型別為 'wint_t' 的寬字元。
返回值
如果寬字元是小寫字母,則此函式返回非零值;否則返回零。
示例 1
以下是一個基本的 C 示例,演示了 iswlower() 函式的使用。
#include <stdio.h>
#include <wctype.h>
#include <wchar.h>
int main() {
wchar_t wc = L'a';
if (iswlower(wc)) {
wprintf(L"The character '%lc' is a lowercase letter.\n", wc);
} else {
wprintf(L"The character '%lc' is not a lowercase letter.\n", wc);
}
return 0;
}
輸出
以下是輸出:
The character 'a' is a lowercase letter.
示例 2
在此示例中,我們使用 iswlower() 列印給定寬字元中的所有小寫字母。
#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 (iswlower(str[i])) {
wprintf(L"%lc ", str[i]);
}
}
return 0;
}
輸出
以下是輸出:
e l l o t u t o r i a l s p o i n t n d i a
示例 3
我們建立一個 C 程式來計算給定寬字元中小寫字母的數量。
#include <stdio.h>
#include <wctype.h>
#include <wchar.h>
int main() {
wchar_t str[] = L"Hello, tutorialspoint India";
int lowercaseCount= 0;
// Iterate over each character in the wide string
for (int i = 0; str[i] != L'\0'; i++) {
if (iswlower(str[i])) {
lowercaseCount++;
}
}
// Print the result
wprintf(L"The wide string \"%ls\" contains %d lowercase letter(s).\n", str, lowercaseCount);
return 0;
}
輸出
以下是輸出:
The wide string "Hello, tutorialspoint India" contains 22 lowercase letter(s).
c_library_wctype_h.htm
廣告