
27 Nov
2006
27 Nov
'06
4:55 p.m.
Eric MALENFANT wrote:
Andrew Schweitzer a écrit:
Is there a standard way to output to multiple streams at the same time?
I would like to pass an ostream to a function, write output strings into that stream, and have them go to both cout and a file. I'd like something like this:
void DoSomething(ostream& ros) { ros << "This goes should go to cout and to a file" << endl; } multi_stream ms; fstream f("out.txt"); ms.add(cout); ms.add(f); DoSomething(ms);
Any suggestions?
Is this supported by the iostream library?
tee_device is probably what you're looking for.
awesome, thanks guys. Man that's a fast response! :) Andy