Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- int main()
- {
- ifstream in("f.txt"); // связываем поток ifstream с файлом f.txt
- ofstream out("g.txt"); // потом ofstream с файлом g.txt
- string line;
- while (getline(in, line)) { // пока считываются строки из потока in (из файла f.txt)
- if (line.find(" ") != string::npos) { // ищем пробел в этой строки и если он найден (find != string::npos)
- out << line << endl; // выводим строку в файл g.txt
- cout << line << endl; // и выводим в консоль
- }
- }
- out.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement