05-12-2011, 09:07 PM
Having problem while storing this code inside the data file.
//includes
//some variables and strings not related to the problem:
float score = 0;
string Name; //User Name for File input;
string prev_score; //Previous User's Score;
ofstream user_score ("Score.txt");
ifstream prev_user("Score.txt");
//Structs, Functions and the main function, that contains calls to these functions.
//Deriving data from file:
while( prev_user.good() )
{
getline (prev_user, prev_score);
cout << prev_score << endl;
}
prev_user.close();
//Inputting Data to file:
user_score << "The previous player was: " << Name << endl;
user_score << Name << " scored " << score << " points.";
user_score.close();
//Termination.......
//includes
//some variables and strings not related to the problem:
float score = 0;
string Name; //User Name for File input;
string prev_score; //Previous User's Score;
ofstream user_score ("Score.txt");
ifstream prev_user("Score.txt");
//Structs, Functions and the main function, that contains calls to these functions.
//Deriving data from file:
while( prev_user.good() )
{
getline (prev_user, prev_score);
cout << prev_score << endl;
}
prev_user.close();
//Inputting Data to file:
user_score << "The previous player was: " << Name << endl;
user_score << Name << " scored " << score << " points.";
user_score.close();
//Termination.......