Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int fds[2];
- pipe(fds);
- if(fork()==0){
- int n;
- char buff[MAX];
- close(fds[0]);
- while((n=read(0,buff,MAX))){
- int i;
- for(i=0;i<n;i++){
- buff[i]=tolower(buff[i]);
- }
- write(fds[1],buff,n);
- }
- }
- else{
- int m;
- char buff2[MAX];
- close(fds[1]);
- while((m=read(fds[0],buff2,MAX))){
- int j;
- int cmp=0;
- char tmp[m];
- for(j=0;j<m;j++){
- if(j>0){
- if(tmp[cmp]!=buff2[j]){
- cmp++;
- tmp[cmp]=buff2[j];
- }
- }
- else{
- tmp[j]=buff2[j];
- }
- }
- write(1,tmp,cmp+1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement