Advertisement
Proff_Ust

file_string

Jun 10th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4. #include <windows.h>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     SetConsoleCP(1251);
  10.     SetConsoleOutputCP(1251);
  11.     ifstream file1("file1.txt");
  12.     ofstream file2("file2.txt");
  13.     if (!file1)
  14.     {
  15.         cout<<"Error";
  16.         return 1;
  17.     }
  18.     else
  19.     {
  20.         string word;
  21.         cout<<"Введите слово"<<endl;
  22.         cin>>word;
  23.         string line;
  24.         while(!file1.eof())
  25.         {
  26.             getline(file1,line);
  27.             if (line.find(word)==string::npos)
  28.                 file2<<line<<endl;
  29.         }
  30.         file2.close();
  31.         file1.close();
  32.         return 0;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement