I don’t know if it is possible to do this. I would like to store the output of various parts of a program in way that I load saved data and display it exactly how it was printed out in the first place.
I know this is probable simple to do in a way, but I’m just wondering if there is a very easy way to make this happen, and to add to an existing program. It would be nice if I could just specify a region of code in which all the output which is printed to the screen is also inserted into a text file, and saved. Is there a boost library I should look at?
You can create a stream buffer which writes to multiple other streams and install it into
std::cout. Essentially, this looks something like this:For more details on how this works you can have a look at articles I wrote on exactly this in comp.lang.c++ and comp.lang.c++.moderated (there were multiple articles, more than a decade old…).