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.
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)
Edit: I tried with popen instead of execvp and didn't work as well
Here it goes part of my code:
#define LSIZ 128
#define RSIZ 10
char line[RSIZ][LSIZ];
FILE *fptr = NULL;
int i = 0;
int tot = 0;
fptr = fopen("casosproduto.txt", "r");
while(fgets(line[i], LSIZ, fptr))
{
line[i][strlen(line[i]) - 1] = '\0';
i++;
}
fclose(fptr);
char* argument_list3[]={"produto",&line[i],NULL};
tot = i;
for(i = 0; i < tot; ++i)
{
execvp("./produto",argument_list3);
printf(" %s\n", line[i]);
}