islower() 函数原型
int islower(int ch);
islower()
函数根据当前的 C 语言环境检查 ch 是否为小写字母。默认情况下,字母 a 到 z(ASCII 值 97 到 122)被认为是小写字母。
如果 ch 的值不能表示为 unsigned char 或不等于 EOF,则 islower()
的行为是未定义的。
它定义在 <cctype> 头文件中。
islower() 参数
ch: 要检查的字符。
islower()返回值
如果 ch 是小写字母,islower()
函数返回非零值,否则返回零。
示例:islower() 函数的工作原理
#include <cctype>
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char str[] = "This Program Converts ALL LowerCase Characters to UpperCase";
for (int i=0; i < strlen(str); i++)
{
if (islower(str[i]))
/* Converting lowercase characters to uppercase */
str[i] = str[i] - 32;
}
cout << str;
return 0;
}
运行程序后,输出将是
THIS PROGRAM CONVERTS ALL LOWERCASE CHARACTERS TO UPPERCASE
另请阅读