From: Gerhard Wolf on
Hi,

is it possible to redirect std::cout (or other streams) to a other target?
For example to a TMemo-Field (Borland C++Builder 2009) so that std::cout
<< "hello world" << endl;
goes to this memo-field?
From: Ulrich Eckhardt on
Gerhard Wolf wrote:
> is it possible to redirect std::cout (or other streams) to a other target?

int main() {
std::ofstream o("output.text");
std::cout.rdbuf(o.rdbuf());
std::cout << "This will not end up on the screen!" << std::endl;
}

> For example to a TMemo-Field (Borland C++Builder 2009) so that std::cout
> << "hello world" << endl; goes to this memo-field?

You will have to write an according streambuffer for that, but it is
possible.

Uli
From: Alex Vinokur on


"Gerhard Wolf" <quisquiliae(a)gmx.de> wrote in message
news:83nl7pFn0bU1(a)mid.individual.net...
> Hi,
>
> is it possible to redirect std::cout (or other streams) to a other target?
> For example to a TMemo-Field (Borland C++Builder 2009) so that std::cout
> << "hello world" << endl;
> goes to this memo-field?


Redirecting cout/cerr <--> file : streambuf-method
http://groups.google.com/group/alt.sources/msg/bb4204134e9956a0

Redirecting cin <--> file
http://groups.google.com/group/alt.sources/msg/3a1d1032e2915ffd

Redirecting stdout <--> file
http://groups.google.com/group/alt.sources/msg/8cfdaef5e8fd79b5

Redirecting stdin <--> file
http://groups.google.com/group/alt.sources/msg/50a6267142360edb