im using a for loop to find the index values of the tied high scores and store them into string list then reference list in the second for loop to output it to screen however it isnt letting me use an array with index i as an index its self. Is there a way around this or maybe an alternative to still doing it this way so I dont have to change all of my code
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void printHighest(Student s[], int length){
int index;
string list[10];//you're never going to have more than 10 people with a tieing highscore.
index = findMax(s, length);
for(int i = 0; i < length; i++){
if(s[i].testScore == s[index].testScore )
list[i] = i;
}
for(int i = 0; i < length; i++){
cout << "Highest grade: " << s[list[i]].testScore
<< " held by " << s[list[i]].fName << " " << s[list[i]].lName << endl;
}
}
for the time being I simply removed the idea of string list and just put the contents of the second for loop into the if statement above it. However, I am still curious as to if I can reference an index of an array in an index of another array.