#includeint main() { std::cout << "Hello, World!" << std::endl; std::cout.flush(); return 0; }
#includeIn this example, an `std::ofstream` object is created to write to a file called "output.txt". Text is written to the file using the `<<` operator as with `std::cout`, and `std::endl` is used to flush the buffer and insert a newline character. The `myFile.flush()` function is called explicitly to ensure that the buffer is flushed immediately. The `std::ostream::flush` function is part of the standard library and is included in the `iostream` header.int main() { std::ofstream myFile("output.txt"); myFile << "This text will be written to a file." << std::endl; myFile.flush(); return 0; }