--Originally published at BRENDA
Here is how I solved the quiz that counts a specific character in a sentence.
I created this function that counts characters:
int countChars (string s, int character) {
int count=0;
for (int i = 0; i<s.length(); i++) {
if (s[i]==character) {
count++;
}
}
Here is my code:
https://github.com/brendaruizt/TC1017/blob/master/quiz3.cpp