统计字符串中的字符个数,但不统计空格和数字,哪里出错了啊?
#include<stdio.h>int length(char []);
int main(){
char val[100];
printf("please input a string:\n");
gets(val);
int num = length(val);
printf("The string has %d characters.",num);
}
int length(char val[])
{
int i,sum = 0;
for(i = 0;val[i] != '\0';i++)
if(val[i] < '0' && val[i] > '9' && val[i] != ' ')//想去掉数字和空格
sum++;
return sum;
}