I need to redirect the output of an executable to a file instead of the standard output. I wonder what the easiest way to achieve that. For example, I have an batch file, which prints out some information on screen when it is executed from command line. Now I want to write a C program, to put the output of the file to a log file (for both UNIX and Windows).
I know it can be achieved by first opening the file, fetching each line of the outputs and then writing each line to the log file. But my feeling is there should be some easier way to reach the same goal.