Advertisement
Guest User

Untitled

a guest
May 21st, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     ifstream in("f.txt");  //  связываем поток ifstream с файлом f.txt
  10.     ofstream out("g.txt"); // потом ofstream с файлом g.txt
  11.  
  12.     string line;
  13.     while (getline(in, line)) { // пока считываются строки из потока in (из файла f.txt)
  14.         if (line.find(" ") != string::npos) { // ищем пробел в этой строки и если он найден (find != string::npos)
  15.             out << line << endl; // выводим строку в файл g.txt
  16.             cout << line << endl; // и выводим в консоль
  17.         }
  18.     }
  19.     out.close();
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement