How do I get my data struc program to enter input about 12 players. I just can not seem to get it. My code below only enters one player. I think I understand the concept but can't seem to make it work.
// Write a prg that stores info. about a soccer player in a struc.
// The program should keep an array of 12 of these structures.
// Each element is for a different player on a team.
// When the program runs it should ask the user to enter the info for
// each player. It should the show a table that lists eahc player's
// number, name, and points scored.
// The program should also calculate and display the total points
// earned by the team.
// The number and name of player that has earned the most points should also
// be displayed.
// My current program only does one person. How do I make the array loop
//through each element for all 12 players.
// struct player soccer; My array to enter 12 players
// int i;
// for (i=0, i<12; i++) My loop to enter 12 player info.
void getData(player *);
cout<<"Enter player data:\n";
cout <<"\n This is what you entered:\n";
// now display the data scored in soccer
cout<<"Name: " << soccer.name <<endl;
cout <<"Number: "<< soccer.no <<endl;
cout <<"Point: " << soccer.point << endl;
// Def of function getData useds a pointer to a player stucture
// variable. The user enters into, which is stored in the variable
void getData(player *p)
cout << "Player's name: ";
cout <<"Player's number: ";
cin.ignore (); //ignore the leftover new line.
cout <<"Points scored by player: ";