#include #include #include #include #include #include char new[20],old[20]; int main() { int fd[2]; pid_t cd; char rb[50]; char wb[50]; int rc; printf("enter name of old file and new file"); gets(old); gets(new); pipe( fd ); int fo = open( old, 0 ); int tf = open( new, 0666 ); if ( fo == -1 || tf == -1 ) { printf( "Opening file failed " ); exit(1); } cd = fork(); if( cd == 0 ) { // inside the child prcocess close( fd[1] ); read( fd[0], rb, sizeof( rb ) ); printf( "The recived string is : %s", rb ); //Writing to the target fileOpen write( tf, rb, strlen( rb ) + 1 ); } else { // inside the parent process close( fd[0] ); // code to read from a text file while( (rc = read( fo, rb, sizeof( rb ) ) > 0 ) ) { write( fd[1], rb, sizeof( rb ) ); } close( fd[1] ); } }