Possible Duplicate:
How to redirect cin and cout to files?
I'm debugging some spaghetti code which writes to the terminal via std::cout and via a third party library called tecla:
http://www.astro.caltech.edu/~mcs/tecla/
I would like to hook myself into the stdout so that I can redirect it to a file. Before saving to file I can convert the strings to hex representations so that I can more easily identify all the control characters they contain.
I can also log to this file various events within the program so as to better understand how the program is working.
Any suggestions on how I might do this?
UPDATE
My program also receives commands on the terminal via std input. It seems doing:
myprogram 9889 > output.txt
or even
myprogram 9889 | xxd
disrupts the program in some manner such that I cant seem to get the program to respond to inputted commands.
The prompt (>) does not appear in output.txt.