Count a character
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
Count a character
Return how many times a given character appears in a C-string. Loop over the characters until the null terminator, adding 1 each time the current character matches target.
Complete int count_char(const char *s, char target) to return how many times target appears in the C-string s.
Click Run to see the output here.