Ok lets try this again.
I have an object of type ofstream (or any type of output
stream, including stringstream). How do I get a copy of
everything that is sent to cout (or anyother output stream)
also sent to this stream?
Essentially I am looking for a more "graceful" way to do
this (assume outfile has been declared and opened):
cout << "Some text" << ..... ;
outfile << "Some text" << ..... ;
This works but as just about anyone can guess it can get
quite irritating for really long output lines.
Essentially I am trying to replace a printf-like function I
am using to do my error logging.
The rdbuf stuff will not work, even if I used correct
syntax.
outfile.rdbuf(cin.rdbuf())
This will have both using the same underlying buffer but
when one sync's with the data the other stream will not be
able to read the data. To make matters worse such code is
not quite thread safe.
Does any one know how to this?
...
Better question, is this even possible?
Thanks in Advance
David McKen
__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
|