Hi guys. I have this code.
Now I can't put data into the array scoresort[x]. I have tried everything. When the scoresort[x] is not an array I can input data. Although when it is an array it crashes my program. It will not process the line.Code:#include <string> #include <iostream> #include <fstream> #include <math.h> #include <sstream> string scoresort[9]; 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";} for(int i;i < 10; i++){ cout << scoresort[0].substr (3,0) << endl; } scorefile.close(); // std::ostringstream o; // o << playerscore; return(PlayerScore); }
This is part of the HighScore section for a game that I am currently making. Any help would greatly be appreciated.


Reply With Quote
Bookmarks