1、
#include <stdio.h> int count(const char *s, int key) { int j = 0; while(*s) { if(*s == key) j++; s++; } return j; } int main(void) { char str[128]; printf("str: "); scanf("%s", str); printf("the number: %d ", count(str, 'c')); return 0; }