#include <stdio.h>
#include <stdlib.h>

#define BUFF_SZ 256

int str_chnum(const char s[], int c) {
    int idx = 0;
    int n = 0;
    
    while (s[idx] != '\0' && idx < BUFF_SZ) {
        if (s[idx] == (char)c) {
            n++;
        }
        idx++;
    }

    return n;
}

int main(void) {
    char *buff = (char*)calloc(sizeof(char), BUFF_SZ);
    char query = 0;

    printf("Input String: ");
    fgets(buff, BUFF_SZ, stdin);

    printf("Input Search Character: ");
    scanf("%c", &query);

    int cnt = str_chnum(buff, query);

    printf("Found %d \'%c\'\n", cnt, query, buff);

    free(buff);

    return 0;
}
