Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(void)
- {
- int fd;
- fpos_t pos;
- printf("stdout, ");
- fflush(stdout);
- fgetpos(stdout, &pos);
- fd = dup(fileno(stdout));
- freopen("stdout.out", "w", stdout);
- f();
- fflush(stdout);
- dup2(fd, fileno(stdout));
- close(fd);
- clearerr(stdout);
- fsetpos(stdout, &pos); /* for C9X */
- printf("stdout again\n");
- }
- void f()
- {
- printf("stdout in f()");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement