Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. /* Define your function here */
  5. int CountCharacters(char userChar, string userString)
  6. {
  7. int count = 0;
  8. int size = userString.size();
  9. for(int i = 0; i < size; i++)
  10. {
  11. if(userString.at(i) == userChar)
  12. {
  13. count++;
  14. }
  15.  
  16. }
  17. return count;
  18.  
  19. }
  20. int main() {
  21. /* Type your code here. Your code must call the function. */
  22. char a;
  23. string b;
  24. cin >> a >> b;
  25. cout << CountCharacters(a,b) << endl;
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement