// EOF test

#include <iostream>

#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;

int main()
{
    string filename = "c:/temp/testfile.txt";
    ifstream fin(filename.c_str());
    int x;

    if (fin.fail()) {
        cerr << "Unable to open file " << filename << endl;
        exit(1);
    }

    cout << boolalpha;
    cout << "fin.eof()=" << fin.eof() << endl;

    while (fin >> x) cout << x << endl;
    cout << "fin.eof()=" << fin.eof() << endl;
    fin.close();
    fin.open(filename.c_str());
    cout << "fin.eof()=" << fin.eof() << endl;
}