int HighScore(int PlayerScore){
int x;
fstream scorefile ("scores.txt");
string line;
if (scorefile.is_open())
{
while (scorefile.good() )
{
getline (scorefile,line);
scoresort[x] = line.c_str();
cout << line << endl;
x++;
}
}
else {cout << "File NOT opening";}
This crashes my code, I do not know why. Maybe a conflicting data type? What data type comes out of .txt? I am trying to input it into an array of strings.
The data is for a high score sorting system. It is in the format SNI4465 where SNI would be the first three letters of a name and number following will be the score.
I will then manipulate this data to get the scores of each. Sort them, then rearrange. Repackage the string and put back into the txt file, ready to be read off when hiscores is called.
Also is there anyway to use classes for this problem?
well line 20: you are putting char* into strings and that might do it
you didnt intiliaze x.
why are you taking an int and then returning it without changing it? and why is it in ()?
Taking an int at the moment due to the code not being fully functional yet, therefore I don't want to change the variable until this first section works. Once the code reorganises the structure of highscores then it will find the place to input the new player score (the variable passed).
Also this has been answered now, Thank you very much guys.
Sorry for duplicate post by the way, I didn't realise moderators had to check all posts, therefore I simply though I did not hit "submit" therefore wrote my post again.
really? mods check all posts? i didnt know that. so this isn't sarsasm i just want to make sure i understand right. you will edit playerscore but your just not right now becuase you wanted to get the other stuff working?