#includeusing namespace std; int main() { cout << "Hello World!" << endl; return 0; }
#includeIn this example, we are using `ofstream` class to create an output file named "output.txt" and write the text "This is some text." into it. Then we are closing the file using the `close()` method. Next, we are using the `ifstream` class to open the same "output.txt" file for reading, and using the `getline()` method to read each line of text from the input file and print it on the console using the `cout` statement. Note: The fstream library is used for file input/output operations in C++#include using namespace std; int main() { ofstream outfile; outfile.open("output.txt"); outfile << "This is some text." << endl; outfile.close(); ifstream infile; infile.open("output.txt"); string str; while (getline(infile, str)) { cout << str << endl; } infile.close(); return 0; }