c语言 11-5

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;
}

原文地址:https://www.cnblogs.com/liujiaxin2018/p/14843028.html