SHARE
TWEET

Untitled

Ravenbvutt Oct 12th, 2017 181 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4. using namespace std;
  5. int main() {
  6.     string str;
  7.     char a;
  8.     cout << "Enter the string: ";
  9.     getline(cin, str);
  10.     cout << endl << "Enter the letter: ";
  11.     cin >> a;
  12.     cout << endl;
  13.     for (int i = 0; str[i] != 0; i++) {
  14.         if (str[i] == a && str[i - 1] == ' ' || str[i] == a && i == 0) {
  15.             while (str[i] != ' ' && str[i] != 0) {
  16.                 cout << str[i];
  17.                 i++;
  18.             }
  19.             cout << ends;
  20.         }
  21.     }
  22. }
RAW Paste Data
Top