islower 是一个标准库函数,用于检查给定字符是否为小写字母
<cctype> 头文件,以便使用 islower 函数。#include<iostream>#include <cctype> // 包含 islower 函数所需的头文件使用 islower 函数:将 islower 函数应用于要检查的字符。该函数返回非零值(通常为1),如果字符是小写字母;否则,返回0。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;}完整示例:下面是一个简单的程序,演示了如何使用 islower 函数检查输入字符是否为小写字母。#include<iostream>#include <cctype> // 包含 islower 函数所需的头文件int main() { char ch; std::cout << "Enter a character: "; std::cin >> ch; 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;}这个程序首先提示用户输入一个字符,然后使用 islower 函数检查该字符是否为小写字母,并相应地输出结果。


