fork download
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. int main(){
  5. int a=0,b=0;
  6. string s;
  7. ifstream file(input.txt);
  8. if (file.is_open){
  9. file >> a;
  10. getline(file, s);
  11. int n=0;
  12. n = atoi(s.c_str());
  13. }
  14. else cout << " error";
  15.  
  16.  
  17. ofstream file1(output.txt);
  18.  
  19. file.close();
  20. return 0;
  21. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:7:15: error: ‘input’ was not declared in this scope
 ifstream file(input.txt);
               ^~~~~
prog.cpp:8:17: error: cannot resolve overloaded function ‘is_open’ based on conversion to type ‘bool’
 if (file.is_open){
                 ^
prog.cpp:17:16: error: ‘output’ was not declared in this scope
 ofstream file1(output.txt);
                ^~~~~~
stdout
Standard output is empty