title: Segmentation fault when using pipe
body: <p>I'm doing assignment that ask to sum two arrays using 10 processes in parallel, so I write this code, and I'm used pipe to IPC between parent and it's child , but it's give me segmentation fault , when it want to read from pipe.</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include&lt;stdio.h&gt;
  struct s {
  int * x ;
  int max , min ;
  } ;
  void sum(int *a , int *b , struct s w , int min , int max , int pipe)
  {
      int i ;
      for(i = min ; i &lt; max ; i++)
      {
          *(w.x+i) = *(a+i)+*(b+i) ; 
      }
      write(pipe , w , sizeof(w)) ;
  }
  int main()
  {
      int i ,min = 0 ,max = 1 ;
      int a[11] = {1,1,1,10,1,1,1,1,1,1,1} ; 
      int b[11] = {1,1,1,10,1,1,1,1,1,1,1} ;
      int c[11]; 
      int fd[2] ;
      int j ; 
      pipe(fd) ; 
      for(i =  0 ; i &lt; 10 ; i++)
      {
          int pid = fork();
          if(pid == 0)
          {
              struct s w ;
              w.max = max ;
              w.min = min ;
              *w.x = c[0] ;
              close(fd[0]) ; 
              sum(a,b,w,min , max , fd[1]);
              printf("Done %d \n" , i);
              exit(0);
          }
          else
          {
              min++;max++;
          }
      }
      struct s w ; 
      for(j = 0 ; j &lt; 10 ; j++)
      {
          //segmentation fault !!
          read(fd[0] , w ,sizeof(struct s)) ;
          for(i =  w.min ; i &lt; w.max ; i++)
          {
              printf("[%d] --&gt; %d \n" ,i , *(w.x+i) ) ;
          }
      }   
      return 0; 
  }
  </code></pre>
  
  <p>any idea ? </p>