Mail Archives: djgpp/1998/06/17/10:02:26
On Wed, 17 Jun 1998, Brett Porter wrote:
> I'm working on a text based project here which uses text windows on
> occasion and shells to other programs.
> I was wondering if it is possible to redirect the output of this program
> into the window. The window will probably use the "conio.h" functions to
> define it, but called programs will ignore this using stdout. Even if the
> programs use cprintf, it won't know the calling programs settings will it?
The usual way to achieve this is to invoke the child programs via the
`popen' library function, then read from the FILE * stream it returns.
This way you get stdout of the child program redirected to you, but it
means that the output won't be seen by the user until the child program
returns and you display the redirected output in your window. From your
description, it is not clear whether this is a problem in your case.
There is no way to redirect output of conio functions, as it goes
directly to the video RAM. Direct console I/O is actually a memory move,
so another program cannot intercept it.
- Raw text -