basics · beginner · ~15 min
Scan a string accumulating a count.
Implement int char_count(const char *s, char c) returning how many times c appears in s.
int char_count(const char *s, char c) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.