Im currently learning c++ and directx 9. I am creating a small game which I want to have a high score system, I have the reading and writing of the files done, I am just stuck on how to sort and insert a new value into my score vector.
My method for reading files into a vector is below:
vector<int> Highscore::readFile()
{
int score;
highScoreIn.open ("Highscore.txt", ios::out | ios::binary);
if (highScoreIn.is_open())
{
while(highScoreIn>>score)
{
scores.push_back(score);
}
highScoreIn.close();
return(scores);
}
else cout << "Unable to open file";
}
I want a function that will check an integer passed into the function against the 5 values I am storing in the vector scores, then insert it into the right place in the vector. Any help on this would be appreciated:)