void EvaluateHighScore(top10scores ListToBeChecked[], unsigned char Time)
{
unsigned char RankTen = ListToBeChecked[9].TimeTaken, loopcounter=0, NewRank=0;
char UsersName[USERNAME_LENGTH], MoveName[USERNAME_LENGTH];
if(Time >= RankTen)
printf("\n\n\tYou Took %d Seconds To Complete The Quiz Well Done\n\tUnfortunatly You Didn't Get A High Score\n", Time);
else
{
printf("\n Please Enter Your Username: ");
fflush(stdin);
gets(UsersName);
for(loopcounter=0; loopcounter<TOPTENSCORES; loopcounter++)
{
if(Time<ListToBeChecked[loopcounter].TimeTaken)
{
NewRank = loopcounter;
loopcounter = STOPLOOP;
}
}
for(loopcounter=9; loopcounter!=NewRank; loopcounter--)
{
//moving time & username
if(loopcounter==NewRank)
{
ListToBeChecked[loopcounter].TimeTaken = Time;
strcpy(ListToBeChecked[loopcounter].Username,UsersName);
}
else
ListToBeChecked[loopcounter].TimeTaken = ListToBeChecked[loopcounter-1].TimeTaken;
strcpy(ListToBeChecked[loopcounter].Username, ListToBeChecked[loopcounter-1].Username);
}
printf("\n\n\tYou Took %d Seconds To Complete The Quiz,", Time);
if(NewRank==0)
printf("\n\n\tWell Done You Have Achieved The New Top Score\n\n");
else
printf("\n\tWell Done You Achieved Rank %d In The Highscore List\n", NewRank+1);
}
}
I have narrowed the problem down to this loop.
what i want is for the new username and score to be put in at the NewRank.
the other part of the code work where it is moving the other scores down but the new name & score are not being inserted.
i dont want to call another function to sort the data as the list is already in order, i just need the last bit to put the name and score into the struct.