Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include "conio.h"
- #include <string>
- using namespace std;
- int main()
- {
- // TASK 1
- ifstream fs("file1.txt");
- ofstream fs2;
- fs2.open("file2.txt");
- fstream fs3("file3.txt", fstream::in | fstream::out);
- // TASK 2
- if (!fs.good())
- cerr << "File1 not found !" << endl;
- if (fs2.fail())
- cerr << "File2 not found !" << endl;
- if (fs3.fail())
- cerr << "File3 not found !" << endl;
- fs2.close(); // only file2.txt opened
- // TASK 3
- fs.open("file2.txt");
- fs2.open("file2.txt");
- fs3.open("file2.txt");
- // TASK 4
- string inText;
- cout << "Enter text you want to save in file :\n";
- getline (cin, inText);
- fs2 << "This magic program saved text you entered! It is as following:\n" << inText << "\n";
- // TASK 5
- char c = 0;
- while (!fs3.eof()) // cout file
- {
- fs3.get(c);
- cout << c;
- }
- fs.close();
- fs2.close();
- fs3.close();
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement