C语言isalpha函数

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38228254/article/details/80136249

看代码:

#include<ctype.h>
#include<stdio.h>
#include <iostream>
using namespace std;

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+1s
输出:The total of letters is 1

因为只有s是数字。

猜你喜欢

转载自blog.csdn.net/qq_38228254/article/details/80136249