I have to do a program for class that is using parallel arrays to store data of a students grades. We are to give the arrays data by using the Linux command "<" when executing the program.
./a.out < inputfile
However, when I run the program I get an infinite loop of the menu that program is using to access the data in the arrays. It looks like the program is skipping the function I'm using to populate the arrays from the function and using the data from the file for the menus scanf() that is in a separate function.
Here is the function that I'm using to populate the arrays:
void populate(int idarray[],int testone[], int testtwo[],float hw[],int max)
{
int counter = 0;
while(scanf("%d", &idarray[counter]) != EOF)
{
if(idarray[counter] != -1)
{
//scanf("%f %d %d", &hw[counter], &testone[counter], &testtwo[counter]);
scanf("%f",&hw[counter]);
scanf("%d",&testone[counter]);
scanf("%d",&testtwo[counter]);
counter++;
}
if(counter == max-1)
break;
}
}
"max" is the bounds of the arrays.
the input file would look like:
1983990 75.6 39 78 1935440 50.03 78 34