Peteroid said:
I'm doing a managed C++ application. Is there a way to re-direct 'cout' to
output destinations other than the 'black console' that comes up?
Specifically, re-direction to a text file?
Here is an example of how I do this:
-----------------------------
#include <fstream>
#include <iostream>
int main(void)
{ std::filebuf fb; // declare a file buffer
// connect this file buffer to a file for output
if(fb.open("test.data", std::ios:

ut))
{
// test write to cout (console)
std::cout << "*** write to console ***\n";
// set cout's buffer to the filebuf and
// save cout's existing stream buffer to sb
std::streambuf *sb = std::cout.rdbuf(&fb);
// test write to cout (the file)
std::cout << "*** write to file ***\n";
// restore cout's old buffer
std::cout.rdbuf(sb);
// close the file
fb.close();
}
// test write to cout (console)
std::cout << "*** back to console ***\n";
}