count为一维数组,count[i]++用法错误
试试下面的:
#include"stdio.h"
void countstr(char *array)
{
int words=0,numbers=0,spaces=0,others=0;
char *p=array;
for(p;*p!='\0';p++)
{
if(((*p>='A')&&(*p<='Z'))||((*p>='a')&&(*p<='z')))
words++;
else if((*p>=48)&&(*p<=57))
numbers++;
else if(*p==32)
spaces++;
else
others++;
}
printf("words=%d,numbers=%d,spaces=%d,others=%d\n",words,numbers,spaces,others);
}
void main()
{
char str[80];
printf("Please input one segment:\n");
gets(str);
countstr(str);
}
