isdigit() islower() isupper()函数简单应用

这三个函数都是用来判断字符类型的。

这三个函数所需的头文件在c语言中都是 #include <ctype.h>

在c++中是 #include <cctype>

下面分别介绍三个函数:

isdigit()  

功能:如果参数是0到9之间的数字字符,函数返回非零值,否则返回零值.

    char c;
    scanf( "%c", &c );
    if( isdigit(c) )
      printf( "You entered the digit %c\n", c );

 islower()

功能:如果参数是小写字母字符,函数返回非零值,否则返回零值。(使用方式与上面相同)

 isupper()

扫描二维码关注公众号,回复: 2365163 查看本文章

功能:如果参数是大写字母字符,函数返回非零值,否则返回零值。(使用方式与上面相同)

猜你喜欢

转载自blog.csdn.net/qq_40788630/article/details/80386677