I've created my structure and now I'm trying to use a couple loops to sort through the data.
struct stats myPlayers[numPlayers]; // this is the struct
This is the function I've created to sort through the stats, as you my have guessed by the name. I want the function to sort through each member and for this example, determine which player has scored the most goals.Code:int sortStats(int numPlayers, struct stats myPlayers)
{
int mostGoals = 0;
int mostGoalsInd = 0;
for (int i=0;i<numPlayers;i++)
{
if (myPlayers[i].goals > mostGoals)
{
mostGoals = myPlayers[i].goals;
mostGoalsInd = myPlayers[i].ind;
}
}
printf("%s scored the most goals this season with %d.\n", myPlayers[mostGoalsInd], mostGoals);
return 0;
}
I'm getting an error at the if statement. I believe it's because it's not recognizing myPlayers[i].whatever. I think I need to have some sort of initialization to tell it where to pull from, which I thought is what I did when putting the struct stats myPlayers in the braces for the sortStats function. Where do you think I'm going wrong?

