Ok! so im making a simple highscore type thing. the person plays the game and receives a score within the game. At the end of the game i have it currently comparing the score received with the score already in place within the highscore text file. the problem im having is getting the recorded score in the file to change with the new highscore received while still meeting the conditions of the if statement. i can set cScore1 = cScore but then the condition won't be met i'm out of ides please help here's a code portion
ofstream Highscore ("Highscore.txt");
if(cScore > cScore1)
{
gotoxy(18,13); cout << "New Highscore! " << endl;
Highscore << name << "|" << cScore1 << endl;
Highscore.close();
}
ifstream Highscores ("Highscore.txt");
if (Highscores.is_open())
{
while ( Highscores.good() )
{
getline (Highscores,line);
cout << line << endl;
}
Highscores.close();
}
sorry if this is confusing but its hard to explain. i have a line in a text file that says the players name and then the score for the player. i want it to replace that text with the name of the player that gets a higher score and replace the score with the higher score. if the next players score is lower than that of the text file then it doesn't change. i cant explain it any better sorry.