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.

My guess would be that this loop

for(loopcounter=9; loopcounter!=NewRank; loopcounter--)
      {

exits when loopcounter equals NewRank so

if(loopcounter==NewRank)
        {
          ListToBeChecked[loopcounter].TimeTaken = Time;
          strcpy(ListToBeChecked[loopcounter].Username,UsersName);
        }

is never executed.

Also, see this about fflush(stdin); and this about gets(UsersName);

this drove me crazy for about 5 hours yesterday i didnt even think to check if it was running >.<

thanks

ARU Student ...

Please refrain from posting assignment code on publically accessible Internet sites.

Sharing code and soliciting for help on-line outside the WebCT forum qualifies as poor academic practice and discplinary procedures will be enforced if you are identified.

Ian

@ianvdl
Are you a teacher / lecturer / TA of this course?

> qualifies as poor academic practice
If you're pushing "gets()" and "fflush(stdin)" as being the height of "academic excellence" then expect a rough time round these parts.

@ianvdl
Are you a teacher / lecturer / TA of this course?

> qualifies as poor academic practice
If you're pushing "gets()" and "fflush(stdin)" as being the height of "academic excellence" then expect a rough time round these parts.

They are warned that those functions are defunct, but they serve a purpose for absolute beginners (in the first few sessions of a programming course) since fgets requires two extra arguments, and scanf sometimes misbehaves in a way that is alleviated with fflush.

I am perfectly aware of the alternatives thankyou, but I have made a decision that it is better to use the simplest methods possible for the introductory sessions and frankly anything you might have to say on the matter is utterly irrelevant.

The student's posting of formally assessed code in a publically accessible forum leads to other students downloading it rather than working on their own solution.

That is my objection to the above student's posting, and the only matter on which I am willing to enter into conversion (i.e., with them, not you).

This article has been dead for over six months. Start a new discussion instead.