Just
redirect the standard output. For instance, if your program's name is
myapp.exe
then, in the console window, type:
myapp.exe > out.txt
that would generate the text file out.txt containing all the standard output of your application.
You may also
programmatically redirect the standard out, see:
"How to redirect stdout to a file from a Visual C/C++ program" at MSDN[
^].