Q:

Using C++ Reading from text file until EOF repeats last line ?

0

Using C++ Reading from text file until EOF repeats last line ?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <iostream>
#include <fstream>
using namespace std;
int main()
{
    ifstream iFile("input.txt");    // input.txt has integers, one per line
    while (!iFile.eof())
    {
        int x;
        iFile >> x;
        cerr << x << endl;
    }
    return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now