OOPp 4
OOPp 4
#include <fstream>
int main()
ofstream outf("example.txt");
if (!outf)
return 1;
outf << "This is a simple file I/O example in C++." << endl;
// Step 2: Open the file again as an input file and read the information
ifstream inf("example.txt");
if (!inf)
return 1;
cout << line << endl; // Output each line read from the file
}
return 0;
OUTPUT