Trouble with reading in data to an array of structs
I've broken down the huge program I was recently assigned into several parts, and this is the first. I'm trying to read in data from an input file and store each piece into structs in an array. Here is the code I developed:
I've tried every solution I could think of, but unfortunately, the program keeps crashing. What am I doing wrong? (P.S. Everything with the struct and file is declared correctly, and I declared the struct array as I was shown in the book.)
//Reads in the input data for the number of players.
fscanf(ifp, "%d", total_players);
//Reads in the other pieces of information from the input file and
//prints to confirm the data was read in successfully.
for(i = 0; i < total_players; i++)
fscanf(ifp, "%s%s", test[i].lastname, test[i].firstname);
printf("%s %s \n", test[i].lastname, test[i].firstname);
for(j = i; j < total_players; j++)
fscanf(ifp, "%d", test[i].numbers[j]);
if(j == 5)