/*编程实现从键盘输入一串字符串和一个字符,统计该字符串中指定字符出现的个数*/
#include<stdio.h>
#include<string.h>
main()
{ char str[100],c;
int i=0,count=0;
printf("请输入一个字符串:");
gets(str);
printf("请输入指定的查找字符:");
scanf("%c",&c);
while(str[i]) /*该循环扫描/遍历字符数组*/
{ if(str[i]==c)
count++;
i++;
}
printf("%d\n",count);
}
编程实现从键盘输入一串字符串和一个字符,统计该字符串中指定字符出现的个数
猜你喜欢
转载自blog.csdn.net/YJG7D314/article/details/89055674
今日推荐
周排行