title: fgets in this program
body: <p>I'm trying to make a C program in UNIX in which the parent process generates two child processes. 
  The parent will read data from stdin and will send it to his children.
  The 1st child will show on screen the text read from his father, to standard output.
  The 2nd child will show the read data in a file. When the parent has as input an "exit", he will send termination signals to  his children and will exit.</p>
  
  <p>So here is the complete code I did, but where I need help is in <code>void ProcesoHijo2()</code>. I still have a warning when I have to compile,this one:</p>
  
  <pre><code>74: warning: passing argument 3 of ‘fgets’ makes pointer from integer without a cast
  /usr/include/stdio.h:624: note: expected ‘struct FILE * __restrict__’ but argument is of type ‘int’ --&gt;in 
  void ProcesoHijo2()
  </code></pre>
  
  <p>The program is in spanish, so the variable names too, I hope that won't be a problem and you can help me soon because I'm desperate...THANK YOU!!!!</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;string.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;signal.h&gt;
  
  int pidHijo1;
  int descrTub1[2];
  
  int pidHijo2;
  int descrTub2[2];
  
  void ProcesoHijo1();
  void ProcesoHijo2();
  void ProcesoPadre();
  
  int main(int argc, char *argv[]) {
  
  
      pipe(descrTub1); 
      pipe(descrTub2);
          pidHijo1 = fork();
  
          if (pidHijo1 == 0) {
              ProcesoHijo1();
              return 0;
          }
  
      pidHijo2 = fork();
  
          if (pidHijo2 == 0)
              ProcesoHijo2();
          else
              ProcesoPadre();
  }
  
  
  void ProcesoHijo1() { 
  char bufferLectura[256];
  
      close(0); 
      dup(descrTub1[0]); 
  
      while (1) { 
          fgets(bufferLectura, 255, stdin); 
          printf("%sn", bufferLectura);
      }
  }
  
  void ProcesoHijo2() { //--&gt;So here is where I have trouble to program...I don't know if it's just something from inside this process or from above...
  char bufferLectura[256];
  int descrFichero;
  
      close(0); 
      dup(descrTub1[0]); 
  
      descrFichero = open("salida.txt", O_CREAT | O_TRUNC, 0600);
      descrFichero = open("salida.txt", O_RDWR | O_TRUNC, 0600);//--&gt;do I need this one?
  
      while(1) { 
          fgets(bufferLectura,255,descrTub1[0]); //--&gt;I have to read it from pipe and save it in bufferLectura, but I don't know how to put it...
          write(descrFichero, bufferLectura, strlen(bufferLectura));
          descrFichero = open("salida.txt", O_WRONLY|O_APPEND, 0600); //--&gt;Is this correct?
      }
  }
  
  void ProcesoPadre() { 
  char bufferLectura[256];
  
      close(2); 
      dup(descrTub1[1]); 
  
      printf("[Proceso padre]Introduce un texto, o exit para salir");
      fgets(bufferLectura, 255,stdin);
  
      while(strcmp(bufferLectura, "exitn")) { 
          fprintf(stderr,"%s/n", bufferLectura); 
          write(descrTub2[1], bufferLectura, strlen(bufferLectura)); 
          printf("[Proceso padre] Introduce un texto, o exit para salir ");
          fgets(bufferLectura, 255,stdin);
      }
  
      kill(pidHijo1, SIGTERM);
      kill(pidHijo2, SIGTERM);
  
  }
  </code></pre>