1. 程式人生 > >C語言isalpha函式

C語言isalpha函式

看程式碼:

#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是數字。