Topic: how to redirect a stream (FILE)?
Author: John_Maddock@compuserve.com (John Maddock)
Date: 1999/04/30 Raw View
>Is there any way to do this?
The normal method is to impliment your own streambuf class and assign
to cerr or clog:
#include <fstream>
int main()
{
std::filebuf* b = new std::filebuf();
b->open("filename", std::ios_base::out);
std::clog.rdbuf(buf);
// your code here....
std::clog << "error text" << std::endl;
// etc..
}
John Maddock
http://ourworld.compuserve.com/homepages/John_Maddock/
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]