I'd say you should have a User structure containing name and scores array. Each time a name is entered, check the array of User structs and see if their name has come up before. If it has, add to their scores, if not, create a new User and add it to the array.
I think the problem with your current struct is that you're trying to store too much information -- allScores, score, userScores.... too many scores. If you just store the scores alongside each user, you can construct all of that information from what you've stored.
Doing this sort of thing in C++ is a pleasanter task than doing it in C. The C way would be to use arrays for the scores and for the users. The struct might be something like:
Code:
struct User
{
string name;
int scores[50];
int numScores;
}
A more C++ way would be to use a vector for the scores. Then the per user info would be:
Code:
struct User
{
string name;
vector<int> scores;
}
You could have an array or vector of Users in the main program. Possibly better would be to use a map. Maps store values indexed by keys. In this case it'd make sense to have a map<string, User> map, with string being the name. That'd mean you wouldn't have to bother searching the array or vector for entered names. Just do:
Code:
map<string, User*> users;
cin >> name;
User * u = users[name];
So yeh, there's a bunch of ways you could implement it, depending on how brave you feel. I'd probably say 'do it with arrays' - the STL containers are brilliant when you really need a dynamically growing list - but for learning about structures and arrays and stuff, a more C like version would probably be more useful.