islower
是一個(gè)C++標(biāo)準(zhǔn)庫(kù)函數(shù),用于檢查給定字符是否為小寫字母
以下是一個(gè)簡(jiǎn)單的示例,展示了如何在C++中使用 islower
函數(shù)處理字符串:
#include<iostream>
#include <cctype> // 包含 islower 函數(shù)所在的頭文件
int main() {
std::string input = "Hello, World!";
for (char c : input) {
if (std::islower(c)) { // 使用 islower 函數(shù)檢查字符是否為小寫
std::cout << c;
}
}
return 0;
}
在這個(gè)示例中,我們遍歷輸入字符串 input
中的每個(gè)字符,并使用 islower
函數(shù)檢查它是否為小寫字母。如果是,則將其輸出到控制臺(tái)。
注意:在使用 islower
函數(shù)之前,請(qǐng)確保已經(jīng)包含了 <cctype>
頭文件。