• isalpha函数和isdigit函数


           函数:isalpha

     

      原型:int isalpha(int ch)

     

      用法:头文件加入#include <cctype>(旧版本的编译器使用<ctype.h>)

     

      功能:判断字符ch是否为英文字母,当ch为英文字母a-z或A-Z时,在标准c中相当于使用“isupper(ch)||islower(ch)”做测试,返回非零值,否则返回零。

     

      PS:{

     

      isupper

     

      原型:extern int isupper(int c);

     

      头文件:<cctype>(旧版本的编译器使用<ctype.h>)

     

      功能:判断字符c是否为大写英文字母

     

      说明:当参数c为大写英文字母(A-Z)时,返回非零值,否则返回零。

     

      附加说明: 此为宏定义,非真正函数。

     

      islower

     

      islower(测试字符是否为小写字母)

     

      相关函数

     

      isalpha,isupper

     

      表头文件

     

      #include<cctype>(旧版本的编译器使用<ctype.h>)

     

      定义函数

     

      int islower(int c)

     

      函数说明

     

      检查参数c是否为小写英文字母。

     

      返回值

     

      若参数c为小写英文字母,则返回TRUE,否则返回NULL(0)。

     

      附加说明:此为宏定义,非真正函数。

     

      }

     

      示例:

     

      #include<ctype.h>

     

      #include<stdio.h>

     

      int main(void)

     

      {

     

      char ch;

     

      int total;

     

      total=0;//初始化

     

      /*统计字母块*/

     

      do

     

      {

     

      ch=getchar();

     

      if(isalpha(ch)!=0)

     

      total++;

     

      }while(ch!='.');//结束符号为 .

     

      printf("The total of letters is %d ",total);

     

      return 0;

     

      }

     

      /*运行结果*/

     

      输入:123456我am侯云江.

     

      输出:The total of letters is 2

    相关函数
    isdigit
    表头文件
    #include<ctype.h>
    定义函数
    int isdigit(char c)
    函数说明
    检查参数c是否为阿拉伯数字0到9。
    返回值
    若参数c为阿拉伯数字,则返回TRUE,否则返回NULL(0)。
    附加说明
    此为宏定义,非真正函数。
    范例
    /* 找出str字符串中为阿拉伯数字的字符*/
    #include<ctype.h>main(){ char str[]="123@#FDsP[e?"; int i; for(i=0;str[i]!=0;i++) if(isdigit(str[i])) printf("%c is an digit character ",str[i]);}
    执行
    1 is an digit character  2 is an digit character  3 is an digit character
  • 相关阅读:
    would clobber existing tag
    已成功与服务器建立连接,但是在登录前的握手期间发生错误。 (provider: TCP 提供程序, error: 0
    C#搭建简单的http服务器,访问静态资源
    使用iis反向代理
    WorkerServices部署为Windows服务
    mongo 操作数据库的方式
    odoo db_name 指定多个数据库
    odoo 如何设置字段变更跟踪
    odoo qweb 视图使用widget
    odoo 代码片段比较全的扩展
  • 原文地址:https://www.cnblogs.com/lipching/p/3855131.html
Copyright © 2020-2023  润新知