Redirecting cerr, cout to a file.
Matt Austern
austern@sgi.com
Fri Apr 14 15:08:00 GMT 2000
Benjamin Kosnik writes:
>
> > I looked in the FAQ for v3, and this one wasn't in there. I'm using
> > assignment in my program to redirect cerr and cout to a file. I do this for
> > debugging purposes, as the program uses fork().
>
> please provide a code snippet that demonstrates what you are trying to
> do, and what you expect, and what you think is broken
Nothing is broken. The original message says "I'm using assignment"
to redirect cerr and cout, and standard streams have no assignment
operator. Class basic_ios explicitly makes operator= private and
undefined.
The standard way of doing this is to open up a filebuf, and reset cout
and cerr's streambuf using rdbuf.
More information about the Libstdc++
mailing list