Advertisement
Crackbone

Untitled

Dec 11th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. void main(void)
  8. {
  9.     // deklaracija objekta in_files klase ulaznog toka
  10.     // uz otvaranje datoteke cities
  11.     ifstream in_file("cities");
  12.     ofstream out_file("filter");
  13.     // provjera uspješnosti otvaranja datoteke
  14.     if (!in_file)
  15.         return;
  16.  
  17.     string string_A;
  18.  
  19.     // petlja za èitanje se prekida kod nailaska na kraj datoteke
  20.     while (!in_file.eof())
  21.     {
  22.         // èitanje jednog stringa iz datoteke
  23.         in_file >> string_A;
  24.         // ispisivanje stringa na ekran
  25.         cout << string_A << " ";
  26.         if (string_A != "zzz")
  27.             out_file << string_A << " ";
  28.    
  29.     }
  30.     getchar();
  31.     // zatvaranje datoteke
  32.    
  33.     in_file.close();
  34.     out_file.close();
  35.  
  36.  
  37.     //otvaranje filtera
  38.     ifstream in_file1("filter");
  39.     if (!in_file1)
  40.         return;
  41.  
  42.     string string_B;
  43.     while (!in_file1.eof())
  44.     {
  45.         in_file1 >> string_B;
  46.         cout << string_B << " ";
  47.     }
  48.     getchar();
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement