Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int count_x(char* p, char x)
- {
- if (p == nullptr)
- return 0;
- int count = 0;
- for (; p != nullptr; ++p)
- {
- if (*p == x)
- ++count;
- }
- return count;
- }
- int main()
- {
- char str[] = "foobar";
- cout << "Count: " << count_x(str, 'o') << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement