file in C++
This is an example write/read a file. ``` #include <iostream> #include <fstream> using namespace std; int main() { ofstream ofile("example.txt"); if(ofile.is_open()){ ofile << "Writing this line to a file\n"; ofile << "Writing another line to a file\n"; ofile.close(); } ifstream ifile("example.txt"); string line; if(ifile.is_open()) { while(getline(ifile, line)) { cout << line << endl; } ifile.close(); } return 0; } ```