Global Replacement of cout

May 11, 2015 at 4:57am
I have a program with lots of couts. Now I'm wanting to save the output to a text file, so I need to replace each cout with fout (my declared command for my output file). Is there a way to globally replace "cout" with "fout" so I don't have to go through and manually change each one?
May 11, 2015 at 5:45am
May 11, 2015 at 7:18am
It really isn't that much trouble once you've mastered the mystical "Search and replace" functionality of whatever editor you're using.
May 11, 2015 at 7:38am
Are you aware that you can redirect stdout/cout to file when you run the program by writing > filename after the command?

 
./your_program > output_file

http://en.wikipedia.org/wiki/Redirection_%28computing%29#Redirecting_standard_input_and_standard_output
Last edited on May 11, 2015 at 7:50am
Topic archived. No new replies allowed.