islower()函数检查字符是否为小写字母(a-z)。
int islower( int arg );
函数islower()采用整数形式的单个参数,并返回type的值int。
即使islower()接受整数作为参数,字符也会传递给函数。在内部,该字符将转换为其ASCII值以进行检查。
它在<ctype.h>头文件中定义。
| 返回值 | 描述 |
|---|---|
| 非零的数 (x > 0) | 参数是小写字母。 |
| 0 | 参数不是小写字母。 |
#include <stdio.h>
#include <ctype.h>
int main()
{
char c;
c='t';
printf("将 %c 传递给islower()时的返回值:%d", c, islower(c));
c='D';
printf("\n将 %c 传递给islower()时的返回值:%d", c, islower(c));
return 0;
}输出结果
将 t 传递给islower()时的返回值: 2 将 D 传递给islower()时的返回值: 0
注意:将小写字母传递给系统上的islower()时,可能会获得不同的整数值。但是,当您将小写字符以外的任何其他字符传递给islower()时,它始终返回0。