//----------------------------------------- // File: eof.cpp // Author: D. Frey // // Demonstration program for handling eof // //----------------------------------------- #include #include using namespace std; int main ( ) { string fileName = "eof.dat"; ifstream inStream; inStream.open( fileName.c_str()); int score; int total = 0; int nrScores = 0; while (inStream >> score) { total += score; ++nrScores; } cout << "Number of Scores: " << nrScores << endl; cout << "Average Score : " << total / nrScores << endl; inStream.close( ); return 0; }