#include
#include
#include
#include
void f(char *s, int *na, int *nd, int* nc, int *no);
int main(){
char s[1000]={'\0'};
int l=0, m=0, n=0,z=0; //保存返回值
printf("Input a String:");
gets(s);
f(s,&l, &m, &n, &z);
printf("字母个数:%d\n", l);
printf("数字个数:%d\n", l);
printf("空格个数:%d\n", l);
printf("其他个数:%d\n", l);
return 0;
}
void f(char *s, int *na, int *nd, int* nc, int *no)
{
int l=0, m=0, n=0,z=0; char c;
while(s&& (c=*s) && s++)
{
if(isalpha(c)) l++;
else if(isdigit(c)) m++;
else if(c==' ') n++;
else z++;
}
*na = l, *nd =m, *nc=n, *no=z;
return ;
}