常用的字符处理函数

  用法:C语言中:#include <ctype.h>

     C++中:#include<cctype>

  isalnum(c):如果c是字母或数字,则为true;

isalpha(c):如果c是字母,则为true;

iscntrl(c):如果c是控制字符,则为true;

isdigit(c):如果c是数字,则为true;

isgraph(c):如果c不是空格,但可打印,则为true;

islower(c):如果c是小写字母,则为true;

isprint(c):如果c是可打印的字符,则为true;

ispunct(c):如果c是标点符号,则为true;

isspace(c):如果c是空白字符,则为true;

isupper(c):如果c是大写字母,则为true;

isxdigit(c):如果c是十六进制数,则为true;

toupper(c):如果c是小写字母,则返回其大写字母形式,否则直接返回c;

 tolower-将大写字母转换成小写字母的函数;

功能:将字符c转换为小写英文字母

  
  说明:如果c为大写英文字母,则返回对应的小写字母;否则返回原来的值。
  
  举例:

      // tolower.c
      
      #include <syslib.h>
      #include <ctype.h>


      main()
      {
        char *s="Hello, World!";
        int i;
        
        clrscr();        // clear screen
        printf("%s\n",s);
        for(i=0;i<strlen(s);i++)
        {
          putchar(tolower(s[i]));
        }
        
        getchar();
        return 0;
      }


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值