函数:isalpha
原型:int isalpha(int ch)
用法:头文件加入#include <ctype.h>
功能:判断字符c是否为英文字母,当c为英文字母a-z或A-Z时,在标准c中相当于使用“isupper(c)||islower(c)”做测试,返回非零值,否则返回零。
示例:
/*本函数运行环境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
",total);
return 0;
}
/*运行结果*/
输入:123456我am侯云江.
输出:The total of letters is 2