#include <stdio.h>
#define N 300
int upper = 0,lower = 0,digit = 0,space = 0,other = 0;
void stat_string(char *);
int main(int argc, char *argv[])
{
char ch[N],*p_ch;
p_ch = ch;
printf("please input a string:\n");
gets(ch);
stat_string(p_ch);
printf("the string :'%s'\nupper = %d , lower = %d , digit = %d , space = %d , other = %d \n"
,p_ch,upper,lower,digit,space,other);
system("pause");
return 0;
}
void stat_string(char *string)
{
char c;
while (c = *string ++)
{
if (c >= 'A' && c <= 'Z')
{
upper ++;
}
else if (c >= 'a' && c <= 'z')
{
lower ++;
}
else if (c >= '0' && c <= '9')
{
digit ++;
}
else if (c == ' ')
{
space ++;
}
else
{
other ++;
}
}
}
|