Reading in from a file

int main(){
char play;
int Score[100];//Score Array
int Plays = 0;//Number of Plays/Array Position
int x;//Loop increment
float tot = 0;//Total Number of Guesses
float avg = 0;//Average overall

cout << "Would you like to play Guess a Number?" << endl;
cout << "Y for Yes or N for No!" << endl;
cin >> play;

if ((play == 'Y') || (play == 'y')){

    cout << "----------------------------New Game----------------------------" << endl;

    while ((play == 'Y') || (play == 'y')){

        int Tries = PlayGame();
        cout << Tries << " Tries" << endl; //test line
        Score[Plays] = Tries;
        Plays++;
        cin >> play;

    }//end play while loop

}//end if
cout << "----------------Highscores----------------" << endl;
cout << "Before you go. Let's check on your scores!" << endl;

for (x = 0; x < Plays; x++){

    tot = tot + Score[x];

}//end for loop

avg = tot / Plays;
cout << "Your average this session was " << avg << "!" << endl;


ifstream HS("HighScore Number Game.txt"); 
if (!HS) {
    cout << "Could not open the file\n";
    return 0;
}
float output;
HS >> output;
cout << output << " was the previous highscore." << endl;


ofstream HS;
HS.open("HighScore Number Guess.txt", ios::out);
HS << avg << endl;
HS.close();


}//end main

This is my entire PlayGame function. The only thing left to do is compare the number in the file, with the one just achieved and WRITE back to the file. I don't know what to do. Right now I just get "no poerator matches these operands for the ofstream.

/r/cpp_questions Thread Parent