前辈指导下,为什么我用指针统计不了字符个数,是不是我又错了
程序代码:
/*统计字符个数,空格,大写字母,小写字母,数字,其他*/ #include<stdio.h> #include<string.h> int main() { int digit=0,uppaph=0,lowaph=0,space=0,others=0; char s[148],*p; gets(s); for(p=s;p<s+strlen(s);p++){ if(48<=*p<=57) digit++; else if(65<=*p<=90) uppaph++; else if(97<=*p<=122) lowaph++; else if(*p==32) space++; else others++; } printf("digit=%d\nuppaph=%d\nlowaph=%d\nspace=%d\nothers=%d\n", digit,uppaph,lowaph,space,others); return 0; }