Beginner C++ student here, first ever programming class. I am trying to put together the program below. It's supposed to ask the user for an input string, then a specific char to look for within that string, and output how many times it appears.
For example:
input: 1+2+3
look for: '+'
It appears 2 times.
I am learning string functions in the format shown in the code, where I call a function. However, I am still learning how to call the function in the main. So, I am wondering if someone kindly advise as to how I can tell the main to use the function howMany and output the 'counter' value from the loop.
First you need to look at how many parameters are in your function 'howMany'.
Surely the first thing is to look at what parameters the function needs in order to do its job.
It needs:
1. the string
2. the character to search for.
The resulting number is passed back to the calling function as the return value.
The variable 'counter' is part of the internal working of the function, the rest of the program doesn't care about what goes on inside the function.