redirect cerr to a string stream
-
Hi Hung! You can use the assignment operator of the cere. Here is the small example which can help you: #include "stdafx.h" #include #include char szBuffer[1024]; ostrstream cstr(szBuffer, sizeof(szBuffer)-1); int main(int argc, char* argv[]) { // put something in the output streams cout << "Standart Output\n"; cerr << "Standart Error\n"; cstr << "***Our String**\n"; // use the assignment operator to change the cerr cerr = cstr; cout << "Standart Output\n"; cerr << "Standart Error After Assigment\n"; // show the content of our cstr //cout << cstr.str(); cout << endl << "Preess ENTER to exit" << endl; getchar(); return 0; } Alex Gorev, Dundas Software. ================== The original message was: Hi,
Does anyone know how to redirect cerr to a string stream?
Thank you
Hung