stdoutis a pointer to the FILE *standard output stream. dup2expects a file descriptor, also you have mixed up the order of the parameters. Use
dup2(file, 1);
instead.
, . , , , system. . dup -, dup2 ( dup ped one). cat, . system , , , ,
system("ls -l > Result");
, () , - 'Result; rm -rf /*' .
, ls, :
system("/bin/ls -l > Result");