字符串数字字母空格其他字符个数统计

在这里插入图片描述

#include<string.h>
void main()
{char a[100],*p=a;
int s,i,b=0,c=0,d=0,e=0;
printf("输入法人字符串是");
scanf("%s",p);
s=strlen(a);
for(i=0;i<s;i++)
{if((*p>='a'&&*p<='z')||(*p>='A'&&*p<='Z'))
b++;
else if(*p>='0'&&*p<='9')
c++;
else if(*p==' ')
d++;
else
e++;
p++;
}
printf("该字符串的字母数目是%d\n数字数目是%d\n空格数目是%d\n其他字符数目是%d\n",b,c,d,e);
}
在这里插入代码片

猜你喜欢

转载自blog.csdn.net/feiqipengcheng/article/details/82988578