CCCPaste

Ex7.4 C Lab

int string_how_many(char c, char s[]) {
    char *sptr = s;
    int count = 0;

    while (*sptr != '\0') {
        if (*sptr == c) {
            count++;
        }
        sptr++;
    }

    return count;
}