I have a bulk of code like this:
struct SoccerTeam
{
string teamName;
int totalGame;
SoccerPlayer playerStore[PLAYERS] = { { "NONE", 0 }, { "NONE", 0 }, { "NONE", 0 }, { "NONE", 0 }, { "NONE", 0 } };
};
//Function prototypes.
void showStats(SoccerTeam team[], bool);
void getTeamInfo(SoccerTeam team[]);
//Main function.
int main()
{
bool flag = true;
SoccerTeam leagueTeam[TEAM] = { { "NONE", 0, "NONE"}, { "NONE", 0, "NONE"}, { "NONE", 0, "NONE"}, { "NONE", 0, "NONE"} };
//Call the function to print out the content of the initialized array.
showStats(leagueTeam, flag);
//Call the function to ask the user to enter values into the array.
getTeamInfo(leagueTeam);
//Call the show stat function again with user's input.
showStats(leagueTeam, flag);
}
And I'm trying to display the initialized array to the screen, by using the function:
//Function that displays the contents of the array to the screen.
void showStats(SoccerTeam team[], bool flag)
{
double averageG = 0.00;
cout << "Data After Initialization:" << endl << endl;
for (int i = 0; i < TEAM; i++)
{
cout << "The team: " << team[i].teamName << " has played " << team[i].totalGame << " games." << endl;
for (int j = 0; j < PLAYERS; j++)
{
cout << right << setw(20) << "Player: " << team[j].playerStore->playerName << " has " << team[j].playerStore->goalScore << " goals. " << endl;
averageG = team[j].playerStore->goalScore / team[j].totalGame;
cout << "The average goals are: " << averageG << endl;
}
}
}
And the output only shows the first and third line. I don't know what's wrong with it. I'm new to structure and yet I have a hard time understanding this:
