fork download
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. //code for week2 homework c++
  5. int main() {
  6. int myStory;
  7. cout << "Hello, user! Let's create your file. We're processing file myStory";
  8. cin >> myStory;
  9. ofstream myfile
  10. myfile.open("myStory.txt");
  11. myfile << "I love to code.\n";
  12. myfile << "I really love to code in C++.\n";
  13. myfile << "Coding makes me very happy.\n";
  14. myfile << "Give me more code to write.\n";
  15. myfile.close();
  16. return 0;
  17. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:10:1: error: expected initializer before ‘myfile’
 myfile.open("myStory.txt");
 ^~~~~~
prog.cpp:11:1: error: ‘myfile’ was not declared in this scope
 myfile << "I love to code.\n";
 ^~~~~~
stdout
Standard output is empty