I've got it setup like this in my own game now (in my restart game function):
FILE* highscores;
highscores = fopen( "highscores.txt", "a" );
fscanf( highscores, "Highscore: %i", ¤tHighscore ); //using "¤tHighscore" or "currentHighscore" doesn't make a difference, only "currentHighscore" gives me more 0's
printf( "%i\n", currentHighscore );
if ((gameObject.score != 0) && (gameObject.score > currentHighscore))
{
fprintf( highscores, "Highscore: %i\n", gameObject.score);
}
fclose( highscores );
It doesn't work yet, as you can see i print currentHighscore in the console as well to check if it works, but everytime it prints "0" twelve times (in the console). My highscores.txt file looks like this ( 500 is higher than the scores i get when testing):
Highscore: 500
and when i restart the game (in game) it still just prints the gameObject.score because it's higher than 0 of course.