Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <fcntl.h>
- int main()
- {
- printf("First: print to stdout \n");
- dup2(1,4);
- close(1);
- open("redirect_out.txt",O_CREAT,0777|O_RDWR);
- printf("Second: print to redirect \n");
- dup2(4,1);
- printf("Third: print to stdout \n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement