Hi,
I just wonder if this is possible:
(semi-pseudocode (won't work as planned))
ofstream fout("my_file.txt");
fout << cout;
Looking forward to your reply

Recommended Answers

All 6 Replies

so you want to output the screen output screen to a file?

Hi,
I just wonder if this is possible:
(semi-pseudocode (won't work as planned))
ofstream fout("my_file.txt");
fout << cout;
Looking forward to your reply

I don't think thats possible if I properly understand what you are asking....

Yes, what I mean is if is possible to "copy" contents any ostream to another ostream like this:
ostream out1 , out2;
//...add something to first one
out2 << out1;
I wonder if it's pos.

>I wonder if it's pos.
Well, just try it then.

Oveload << operator.

When the hoops you have to jump through to get this kind of behavior through the library are both advanced and somewhat obscure, one wonders what's so hard about manually writing to fout each time you write to cout (or calling a function that does it for you)...

commented: Simple and clever :) +17
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.