Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /* Define your function here */
- int CountCharacters(char userChar, string userString)
- {
- int count = 0;
- int size = userString.size();
- for(int i = 0; i < size; i++)
- {
- if(userString.at(i) == userChar)
- {
- count++;
- }
- }
- return count;
- }
- int main() {
- /* Type your code here. Your code must call the function. */
- char a;
- string b;
- cin >> a >> b;
- cout << CountCharacters(a,b) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement