Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstring>
- using namespace std;
- int count(char str[], char ch)
- {
- int size;
- int i(0);
- int cnt;
- size = strlen(str);
- for(int i = 0; i<size; i++)
- {
- if(str[i] == ch)
- cnt++;
- }
- return cnt;
- }
- int main()
- {
- char a[1000];
- char ch;
- int cnt ;
- cin >> a;
- cout << "Enter the serching charactor";
- cin >> ch;
- cnt = count(&a[0], ch);
- cout << cnt <<'\n';
- }
Add Comment
Please, Sign In to add comment