If you use std::fstream, you would open the file, check if the deaths are lower, and write to the file. So...
#include <fstream>
int currentScore; // Holds players score
fstream myfile ("scores.txt"); // Opens file
string line; // String to hold line info
if (myfile.is_open()) // Open file
{
while ( myfile.good() ) // While file is valid
{
getline (myfile, line); // Read line
if (atoi(line) > currentScore) // Check score
myfile << currentScore; // Write score to file
else
break; // score is not greater, so exit loop
}
myfile.close(); // Close file
}
So now you can create a file "scores.txt" and put one 0 in it to make sure the first player will be recorded. (Or you could modify the code to do that
)