多谢各位的指点,我已经改好了。
#include"stdio.h"
#include"string.h"
int statistics(char a[],int *count,int *num,int *space,int *other);
int main()
{
int count=0,num=0,space=0,other=0;
char a[50];
gets(a);
statistics(a,&count,&num,&space,&other);
printf("字母的个数:%d,数字的个数:%d,空格的个数:%d,其他字符的个数:%d\n",count,num,space,other);
return 0;
}
int statistics(char a[],int *count,int *num,int *space,int *other)
{
int i;
for(i=0;i<strlen(a);i++)
{
if((a[i]>='a'&&a[i]<='z')||(a[i]>='A'&&a[i]<='Z'))
(*count)++;
else if(a[i]>='0'&&a[i]<='9')
(*num)++;
else if(a[i]==' ')
(*space)++;
else
(*other)++;
}
return 0;
}