isalpha islower toupper

isalpha
  原型:extern int isalpha(int c);
  
  用法:#include <ctype.h>
  
  功能:判断字符c是否为英文字母
  
  说明:当c为英文字母a-z或A-Z时,返回非零值,否则返回零。
  
  举例:

      // isalpha.c
      
      #include <syslib.h>
      #include <ctype.h>
      #include <stdio.h>

      main()
      {
        int c;
        
        clrscr();        // clear screen
        printf("Press a key");
        for(;;)
        {
          c=getchar();
          clrscr();
          printf("%c: %s letter",c,isalpha(c)?"is":"not");
        }
        return 0;	// just to avoid warnings by compiler
      }
      
  相关函数:isalnum,isdigit,isxdigit,iscntrl,isgraph,isprint,ispunct,isspace

#include <stdio.h>
#include <ctype.h>
#define LENGTH 11
int main()
{
        char c[LENGTH] = {"CHinA No.1"};
        int i;
        puts(c);
        for (i = 0; i < LENGTH - 1; i++) {
                if (isalpha(c[i])) {
                        if (islower(c[i]))
                                c[i] = toupper(c[i]);
                }
        }
        puts(c);
        return 0;
}
输出结果:CHinA No.1 
                    CHINA NO.1
 函数:isalpha
  原型:int isalpha(int ch)
  用法:头文件加入#include <cctype>(C语言使用< ctype.h>)
  功能:判断字符ch是否为英文字母,当ch为英文字母a-z或A-Z时,在标准c中相当于使用“isupper(ch)||islower(ch)”做测试,返回非零值(不一定是1),否则返回零。
  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)。
  附加说明:此为宏定义,非真正函数。
  }
  示例:
  /*本函数运行环境 Visual C++ 6.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 \n",total);
  return 0;
  }
  /*运行结果*/
  输入:123456我am侯云江.
  输出:The total of letters is 2
 

touppetoupper - 函数功能

原型:extern int toupper(int c);
  
  用法:#include <ctype.h>
  
  功能:将字符c转换为大写英文字母
  
  说明:如果c为小写英文字母,则返回对应的大写字母;否则返回原来的值。

toupper - 函数示例


  举例:


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

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

 
 
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值