Count One Letter While Stepping a char Pointer
easyQuestion 448Complete int countLetter(const char *s, char target) so it returns how many times target appears in the string s. Walk the pointer one character at a time and compare the character it points at.
main is already written: it reads a word on the first line and a single letter on the second line, then prints the count.
For the input: banana a
Print exactly what is shown in Expected Output.
Expected output
Count: 3= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Pointers
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (p, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.