file - read the last line twice -
ifstream infile("score.txt", ios::in); int score; while(infile.good()){ infile >> score; cout << score << endl; }
i tried read scores file , print them. last score being read twice. tried other condition such while(!infile.eof()), nothing changes. confused this.
the score file looks following: 78 23 43 23 54
the "54" read , printed twice.
try one......
ifstream infile("score.txt",ios::in); int score; infile >> score; // before loop read 1 time while(infile.eof()) { infile >> score; cout << score << endl; }
Comments
Post a Comment