Reputation: 1995
The C system() call runs a program and forwards both stdout and stderr of the command that is run to the stdout and stderr streams of the calling program.
Is it possible to redirect stdout from the command inside the system() call to the stderr stream of the calling program?
Upvotes: 0
Views: 1790
Reputation: 125
Just append 1>&2
to the command executed in your system call:
Example:
system("ls 1>&2");
will execute ls
and redirect stdout (1) to stderr (2).
Upvotes: 2