How do I save the console to a text file?

I'm making a program that talks to the user. When the program is done, how do I save what was said to a text file so the user can read it later? Thanks.
Use file streams. Example code would be:
1
2
3
4
5
6
7
8
std::ofstream fout("hello.txt");

// Displayed to the console
std::cout << "Hello.";
// Displayed to the file
fout << "Hello.";

fout.close();


Reference: http://www.cplusplus.com/doc/tutorial/files/
Write to the file as your program runs instead of try to collect all of the data at the end.
Topic archived. No new replies allowed.