Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <fcntl.h>
  5.  
  6. int main()
  7. {
  8. printf("First: print to stdout \n");
  9. dup2(1,4);
  10. close(1);
  11. open("redirect_out.txt",O_CREAT,0777|O_RDWR);
  12. printf("Second: print to redirect \n");
  13. dup2(4,1);
  14. printf("Third: print to stdout \n");
  15. return 0;
  16.  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement