Copying and modifying array elements

The for loop in which you copy the values from oldscores to newscores is never run in the case of SCORES_SIZE == 1, since SCORES_SIZE - 1 == 0, and 0 < 0 is false immediately.

Move the newScores[SCORES_SIZE - 1] = oldScores[0]; line outside the for loop:

for (i = 0; i < SCORES_SIZE - 1; i++) {
  newScores[i] = oldScores[i + 1]; 
}
newScores[SCORES_SIZE - 1] = oldScores[0];

Leave a Comment