Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstring>
- using namespace std;
- int main() {
- string str;
- char a;
- cout << "Enter the string: ";
- getline(cin, str);
- cout << endl << "Enter the letter: ";
- cin >> a;
- cout << endl;
- for (int i = 0; str[i] != 0; i++) {
- if (str[i] == a && str[i - 1] == ' ' || str[i] == a && i == 0) {
- while (str[i] != ' ' && str[i] != 0) {
- cout << str[i];
- i++;
- }
- cout << ends;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement