Добрый вечер. Не могу решить задачу, может кто подскажет в чем ошибка?
_ ./pr1<f.dat>f.rez _
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <stddef.h>
#include <stdlib.h>
#include <errno.h>
int main(int argc, char *argv) {
printf(“Число переданных параметров программе %s = %d\n”, argv[0], argc);
int p = fork();
if (p == -1) {
perror(“error fork”);
exit(1);
} else if (p == 0) {
int fdr = open(argv[2], O_WRONLY);
if (fdr == -1) {
perror(“error file for read”);
exit(2);
}
dup2(fdr, 1);
close(fdr);
execlp(“argv[0]”, “argv[0]”, “argv[1]”, NULL);
} else {
wait(NULL);
/*int fdw = open(argv[2], O_WRONLY | O_CREAT, 0666);
if (fdw == -1) {
perror(“error file for write”);
exit(3);
}
dup2(fdw, 1);
close(fdw);
execl(“argv[1]”, “argv[1]”, “argv[2]”, NULL);
perror(“error”);
exit(4);*/
}
return 0;
}