|
C++: Save Console Output to a File |
|
|
|
Written by Jalil
|
|
Thursday, 13 March 2008 |
The most annoying thing when developing console applications (especially under windows) is when you cannot see the entire output when it is too long for the command line window to handle. The only way around this is to print the output to a file that you can later open and read. You can usually do this by instantiating an output stream and write to it. But there is a simpler and tidier way to achieve that. Include this line in your Main function: std::freopen("output.txt", "w", stdout); What this function does is that it redirects the standard output stream "cout" to the file you specify in its first argument. Simple, Tidy and Useful.
|
|
Last Updated ( Monday, 14 April 2008 )
|