Mail Archives: djgpp/1998/11/03/01:35:24
Mapson wrote:
>
> There is one point in my program where I call another program (using
> system("program.exe") ), and I am interested in redirecting (and
> silencing at the console) the output of that program to a file I
> already have opened for output. This is something I'd previously done
> in a batch file with ">>"
>
> freopen() basically works, but it doesn't silence the output to the
> console. Is there a better way?
A non-standard way is to do a:
int fd;
close(1);
fd = open("yourfile", O_WRONLY | O_CREAT | O_APPEND);
on start up of your program. That way fd will be 1, which is stdout to
most programs.
--
Weiqi Gao
weiqigao AT a DOT crl DOT com
- Raw text -