How is it getting corrupted? Just what is the problem behavior?
Now, I should mention that the way you have the for() loops indexed is potentially problematic, because you are starting at 10 on each of them. Why would this be a problem? Because a ten-element array would have indices from 0 to 9, not 0 to 10. The result is that, from the very start, you are walking off of the end of the array. If you change the initialization so that it begins at 9, rather than 10 - or better still use a named constant - you should avoid this problem.
const int SCORE_COUNT = 10;
int main()
{
string names[SCORE_COUNT];
int score[SCORE_COUNT];
for(int scores = SCORE_COUNT - 1; scores >= 0; scores--)
{
cout << "What is your score? ";
cin >> score[scores];
cout << endl;
}
Of course, it would be more conventional to do it like this:
for(int scores = 0; scores > SCORE_COUNT; scores++)
{
cout << "What is your score? ";
cin >> score[scores];
cout << endl;
}
but I gather you have some particular need for the scores to be stored in reverse order.
Schol-R-LEA
Veteran Poster
1,019 posts since Oct 2010
Reputation Points: 414
Solved Threads: 163
Skill Endorsements: 10