Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <unistd.h>
  2. #include <sys/types.h>
  3. #include <unistd.h>
  4. #define EOF -1
  5. #define STD_IN 0
  6. #define STD_OUT 1
  7.  
  8. int main(int argc, char *argv[]){
  9.  
  10. int fd[2];
  11. int c;
  12. pipe(&fd[0]);
  13. if (fork()!=0){
  14. close(fd[0]) ;
  15. close(STD_IN);
  16. //close(STD_OUT);
  17. dup(fd[1]);
  18. close(fd[1]);
  19. execlp("/bin/cat","cat","hola.txt", NULL);
  20. } else {
  21. close(fd[1]);
  22. close(STD_IN);
  23. dup(fd[0]);
  24.  
  25. while((c=getchar())!= EOF){
  26. if(c=='A')
  27. putchar('X');
  28. else
  29. putchar(c);
  30. }
  31. execlp("sort","sort",NULL);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement