title: Write and read on pipe a list of unknown size
body: <p>I want to write on a pipe an array with an unknown size.The array's values are read from stdin. Below is a part of the code that i have written so far. The problem is that using the <code>count</code> variable i am writing exactly 0 bytes. When i should allocate memory for the array in which i perform the read? It's there a better way to make this work?</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;unistd.h&gt;
  
  int main(){
  
  int fd[2];
  int *values;
  int *received;
  pid_t child;
  int count = 0;
  if(pipe(fd) != 0){
      perror("pipe");
  }
  if((child = fork()) &lt; 0){
      perror("fork");
  }
  else if(child == 0)
  {
      close(fd[0]);
  
      while(enteringValues){
          //get values from stdin
          //allocating memory for each read element
          count++;
      }
      write(fd[1],values,count*sizeof(values[0]));
      close(fd[1]);
      exit(0);
  }
  close(fd[1]);
  int i;
  int nbytes = read(fd[0],&amp;received,count*sizeof(received[0]));
  for(i = 0;i&lt;count;i++){
      printf("%d received \n",received[i]);
  }
  return 0;
  }
  </code></pre>