structures, keeping high scores of users
Write a program that allows a user to enter high scores of a game, keeping tracking of the name
of the user and the score. Add the ability to show the highest score for each user, all scores for a
particular user, all scores from all users, and the list of users.
This is the program I am trying to write, however I am having difficulty storing the users name and high score, I know I need to store an array for the score but getting confused because of the structure. (By the way I have to use structures as it is a problem from the structures chapter of the ebook I am doing). Below is my code so far. thanks.
Code:
#include <iostream>
#include <string>
using namespace std;
struct highScore
{
string user;
int score;
int highestScore;
int allScores;
int allUserScores;
};
int main()
{
int entries;
cout << "How many users would you like to enter high scores for?" << endl; //prompts user for no of entries
cin >> entries;
highScore userScore[entries];
for(int i=0; i<entries; i++) //loop prompts user for name and score
{
cout << "Please enter the name for the user" << endl;
cin >> userScore[i].user;
cout << "Please enter the scores for " << userScore[i].user << endl;
cin >> userScore[i].score;
}
for (int i = 0; i < entries; i++) //displays username and score
{
cout << userScore[i].user << " has the score of " << userScore[i].score << endl;
}
return 0;
}