title: how to use execvp() and fclose()?
body: <p>I'm making a program that reads a text file with different numbers each line and put that numbers in a string. (could be in a array of integer but I need to use the function execvp so I guess i need do as a string). Then it uses a second program to calculate the square of that numbers.</p>
  <p>The problem is: I can't pass the arguments to the functions execvp and function execvp is not working. (I guess is something with the fopen)</p>
  <p>Edit: I tried with popen instead of execvp and didn't work as well</p>
  <p>Here it goes part of my code:</p>
  <pre><code>#define LSIZ 128
  
  #define RSIZ 10
  
  char line[RSIZ][LSIZ];
  FILE *fptr = NULL;
  int i = 0;
  int tot = 0;
  
  fptr = fopen(&quot;casosproduto.txt&quot;, &quot;r&quot;);
  while(fgets(line[i], LSIZ, fptr)) 
  {
      line[i][strlen(line[i]) - 1] = '\0';
      i++;
  }
  fclose(fptr);
  
  char* argument_list3[]={&quot;produto&quot;,&amp;line[i],NULL};
  tot = i;    
  for(i = 0; i &lt; tot; ++i)
  {
      execvp(&quot;./produto&quot;,argument_list3);
      printf(&quot; %s\n&quot;, line[i]);
  }
  </code></pre>