I know how to use the rdbuf method to redirect the std::cout stream to std::ofstream but I wanted to "copy" the contents of std::cout to std::ofstream so that I only have to call std::cout and the message goes both to std::cout and std::ofstream?
Asked
Active
Viewed 78 times
0
-
http://stackoverflow.com/a/18331432/179910. You'll have to write to the object you create instead of `cout`, but otherwise exactly what you're asking for. – Jerry Coffin Aug 31 '14 at 13:59
-
If you want to capture the output of a program in a file and still have it available as "normal" output, use the `tee` program. Yep, doesn't answer your question but hopefully gives you what you want instead. ;) – Ulrich Eckhardt Aug 31 '14 at 14:29