Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. void fin_file(ifstream& fin, ofstream& fout, char& next);
  6. void fout_file(ifstream& fin, ofstream& fout, char& next);
  7. void write_file(ifstream& fin, ofstream& fout, char& next);
  8. void closing_message();
  9.  
  10. int main()
  11. {
  12.     char next;
  13.     ifstream fin;
  14.     ofstream fout;
  15.     fin_file(fin,fout,next);
  16.     closing_message();
  17.     return 0;
  18. }
  19.  
  20. void fin_file(ifstream& fin, ofstream& fout, char& next)
  21. {
  22.     fin.open("input.txt");
  23.     if(!fin.fail()) {
  24.         fout_file(fin, fout, next);
  25.     }
  26.     return ;
  27. }
  28.  
  29. void fout_file(ifstream& fin, ofstream& fout, char& next)
  30. {
  31.     fout.open("output.txt");
  32.     if(!fout.fail()) {
  33.         write_file(fin, fout, next);
  34.     }
  35.     return ;
  36. }
  37.  
  38. void write_file(ifstream& fin, ofstream& fout, char& next)
  39. {
  40.     fin.get(next);
  41.     while(next != '\n')
  42.     {
  43.         fout.put(next);
  44.         fin.get(next);
  45.     }
  46.     fin.putback(next);
  47. }
  48.  
  49. void closing_message()
  50. {
  51.     cout << "End of program\n";
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement