I think there there is a *nix shell conmmand that will do it (tee ??) but not in MS-Windows. you might put the output lines into a function then call it twice
void foo(ofstream& out)
{
out << "Hello World " << endl;
}
int main()
{
ofstream out("file.txt");
foo(out);
foo(cout);
}
Ancient Dragon
Retired & Loving It
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>if there a command that do it?
No, the framework doesn't exist for this, so you would need to add it on your own. You *can* do it with standard streams such that a single write statement copies to a file or vector of files that you choose, but that's an extremely advanced IOStreams technique that involves extending your own tee'd stream, and it's much easier to just explicitly do two writes like Ancient Dragon showed.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401