islower
是 C++ 標(biāo)準(zhǔn)庫(kù) <cctype>
中的一個(gè)函數(shù),用于檢查給定的字符是否為小寫(xiě)字母。如果字符是小寫(xiě)字母,該函數(shù)返回非零值(true),否則返回零(false)。
這個(gè)函數(shù)的原型如下:
int islower(int c);
其中,參數(shù) c
是要檢查的字符。
以下是一個(gè)簡(jiǎn)單的示例,展示了如何使用 islower
函數(shù):
#include<iostream>
#include <cctype>
int main() {
char ch = 'a';
if (std::islower(ch)) {
std::cout << "The character is a lowercase letter."<< std::endl;
} else {
std::cout << "The character is not a lowercase letter."<< std::endl;
}
return 0;
}
在這個(gè)示例中,我們檢查字符 ch
是否為小寫(xiě)字母。由于 ch
是小寫(xiě)字母 ‘a(chǎn)’,所以輸出將是 “The character is a lowercase letter.”。