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