title: how to send the pipe from parent to child process
body: <p>I am trying to use the fork to create three child process, two of them will write string of char to pipe will the third one will read it from pipr and output it one the screen. We are supposed to create 4 files and call exec system call to access those file. but I have no idea how to send the pipe to other process. Since I tried in the main process to create     fd[2]     and     pipe(fd)     in the child process call close(fd[0]), but it gives me undeclared? how could I do this. 
  here's my code</p>
  
  <pre><code>   int main(void){
  int fd[2],z,status,i;
  pid_t childB, childC, childD;
  char *arg[1] = {0};
  z = pipe(fd);
  if(z &lt;0 ){perror("create pipe"); exit(0);}
  
  childB = fork();
  if(childB==0){execv("PipeW1",arg);}
  if(childB&lt;0){printf("fork failed\n");exit(0);}
  ....
  </code></pre>
  
  <p>and in the PipeW1 method, I did this: </p>
  
  <pre><code>    void main (int argc, char *argv[]){
      int i;
      char str[6];
      close(fd[0]);   
      for(i=1;i&lt;=500;i++){
      sprintf(str,"%03daaa",i);
      z = write(fd[1],str,6);
      if(z&lt;0) {perror("write process B"); exit(1);}
      if(i%100==0){usleep(100000);}
  }
  close(fd[1]);
  exit(0);
  }
  </code></pre>
  
  <p>any suggestions will be helpful!</p>
  
  <p>Thanks</p>