Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <sstream>
- using namespace std;
- int main()
- {
- int i, count;
- int counter = 0;
- string str, word;
- char ch;
- cout << "String:\n";
- getline(cin, str);
- cout << "Letter:\n";
- cin >> ch;
- stringstream words(str);
- while (words >> word)
- {
- i = 0;
- count = 0;
- while (word[i])
- {
- if (word[i] == ch)
- {
- count++;
- counter++;
- break;
- }
- i++;
- }
- cout << word << " " << count << endl;
- }
- cout << endl << "Total: " << counter << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement