fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. fstream file;
  7. ifstream ifile("file.txt", ios::in);
  8. ofstream ofile("file2.txt", ios::out | ios::app);
  9.  
  10. if (!ifile.is_open()) {
  11.  
  12. cout << "file not found";
  13. }
  14. else {
  15.  
  16. ofile << ifile.rdbuf();
  17. cout<<"file copied!";
  18. }
  19.  
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
file not found