c程序查找字符出现次数

#include <stdio.h>
int main(){
    char str[100],ch,M,Empty;
	int i, frequency = 0;
	
    fgets(str, (sizeof str / sizeof str[0]), stdin);

	scanf("%c",&ch);
	scanf("%c",&M);
	scanf("%c",&Empty);

	for(i = 0; str[i] != ''; ++i)
	{
		if(ch == str[i])
			++frequency;
	}
	printf("字符 %c 在字符串中出现的次数为 %d
", ch, frequency);
	return 0;
}

  

原文地址:https://www.cnblogs.com/todarcy/p/11116290.html