Ok I am working on this program, I input the information it is supposed to pass it to the structures and then display, but its not there to display, and I know the information can't be missing since the math for the total which is done before displaying is done correctly, please help me find my mistake.
// This program is meant to ask user for name, number and points scored
// of 12 soccer players and display a table with the information and
// additional information on how many points the team scored as a whole
// Javier Falcon
// Directories
#include <iostream>
#include <iomanip> // setfill and setw
#include <cstdlib>
using namespace std;
// Constants
const int PLAYER_NAME = 50;
const int NUM_IN_TEAM = 3;
// Structure PlayerInfo with its members
struct PlayerInfo
{
char name[PLAYER_NAME];
int number,
ptScored;
};
// Prototypes
int teamScore(PlayerInfo []);
PlayerInfo getPlayerInfo (int);
PlayerInfo displayPlayerInfo(int);
int main()
{
// Declaration and initialization of PlayerInfo in array variable players
PlayerInfo players[NUM_IN_TEAM];
// Variable to hold the total of points scored by team
int teamPts;
// Title
cout << "International Soccer" << endl << setfill ('-') << setw(20) << "-" << endl;
// Loop to fill players array structure
for(int i = 0; i < NUM_IN_TEAM; i++)
{
players[i] = getPlayerInfo(i);
cin.ignore(); // Empty buffer after every structure
}
// Space
endl(cout);
// Send structures to teamScore fuction for calculation
teamPts = teamScore(players);
// Send structures and total points to displayPlayerInfo for displaying
displayPlayerInfo(teamPts);
system("PAUSE");
return EXIT_SUCCESS;
}
//****************************************************************************//
// Name: getPlayerInfo
// Receives: i
// Sends: dInfo
// Description: This function receives struct and fills members while using i
// to display number in display lines
//
//****************************************************************************//
PlayerInfo getPlayerInfo (int i)
{
// Declaration and initialization of PlayerInfo through dInfo
PlayerInfo dInfo;
// Ask user for information
endl(cout);
cout << "Please enter player " << i + 1 << "'s name: ";
cin.getline(dInfo.name, PLAYER_NAME);
cout << "Please enter player " << i + 1 << "'s number: ";
cin >> dInfo.number;
cout << "Please enter player " << i + 1 << "'s points scored per game: ";
cin >> dInfo.ptScored;
// Return dInfo back to main
return dInfo;
}
//****************************************************************************//
// Name: teamScore
// Receives: Array of PlayerInfo struct
// Sends: total
// Description: This function array PlayerInfo to use member ptScored to
// calculate total of points scored by team
//
//****************************************************************************//
int teamScore(PlayerInfo playerArray[])
{
// Variable to hold total
int total = 0;
// Loop to add the scores together
for(int i = 0; i < NUM_IN_TEAM; i++)
{
total += playerArray[i].ptScored;
}
// Return total to main
return total;
}
//****************************************************************************//
// Name: displayPlayerInfo
// Receives: Array of PlayerInfo struct and teamPts
// Sends: N/A
// Description: This function receives all the information and displays it
//
//****************************************************************************//
PlayerInfo displayPlayerInfo(int pts)
{
PlayerInfo pInfo[NUM_IN_TEAM];
// Title
cout << "Team Information: " << endl << setfill ('-') << setw(20) << "-" << endl;
// Loop to display data
for(int i = 0; i > NUM_IN_TEAM; i++)
{
cout << "Player Name: " << pInfo[i].name;
cout << " " << "Player Number: " << pInfo[i].number;
cout << " " << "Player Points Scored: " << pInfo[i].ptScored << endl;
}
// Display the total Score
cout << "The Team's Total Points Scored: " << pts << "." << endl;
}