Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <sys/types.h>
- #include <unistd.h>
- #define EOF -1
- #define STD_IN 0
- #define STD_OUT 1
- int main(int argc, char *argv[]){
- int fd[2];
- int c;
- pipe(&fd[0]);
- if (fork()!=0){
- close(fd[0]) ;
- close(STD_IN);
- //close(STD_OUT);
- dup(fd[1]);
- close(fd[1]);
- execlp("/bin/cat","cat","hola.txt", NULL);
- } else {
- close(fd[1]);
- close(STD_IN);
- dup(fd[0]);
- while((c=getchar())!= EOF){
- if(c=='A')
- putchar('X');
- else
- putchar(c);
- }
- execlp("sort","sort",NULL);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement