1 #include <unistd.h>
2 #include <stdio.h>
3
4 FILE* Freopen(const char *fileName, const char *type, FILE *stream){
5 FILE *fileFp = fopen(fileName, type);
6 int fd1 = fileno(fileFp);
7 int fd2 = fileno(stream);
8 if(dup2(fd1, fd2) < 0) return NULL;
9 else return stream;
10 }
时间: 2024-12-21 15:39:59