This is the mail archive of the egcs@egcs.cygnus.com mailing list for the EGCS project. See the EGCS home page for more information.
Hi,
(Embedded
image moved nbecker@fred.net
to file: 05.03.99 22.33
pic05277.pcx)
I want to redirect cout to a file. We have an assign operator for
cout, but it doesn't work, and the source iostream.cc says it's not
really supported.
So how do you make this work portably?
This is definitely not topic of this e-mail list: It is just about a
feature of the standard C++ library.
Questions like this are best directed to one of the newsgroup
comp.lang.c++, comp.std.c++,
or comp.lang.c++.moderated. In the latter you will find an answer to
exactly this question when
you look up the "Guru of the Week" (GoF) number 48. The short answer: Use
cout.rdbuf(file.rdbuf());
This is the standard approach to solve this problem.