I have a question about recording the output of a C++ win32 console application.

I'm using visual C++ and would like to know if there is a simple or standard way to record everything your program outputs in the console into a text file?

Will I need to write functions to do the file handling, or is there already built in capability, or any existing code out there for handling this exact purpose?