I'm getting an eofbit exception when I run this function. I'm not sure where I've gone wrong with setting this function up. Can anyone tell me what I've done wrong here?
I would really appreciate ANY advice.

void loadFiles()
{
    ifstream file;
    file.exceptions ( ifstream::eofbit | ifstream::failbit | ifstream::badbit );

    Room tempRoom;

    try
    {
        int count = 0;
        file.open("CustFile.txt");

        if (!file.eof())
            file >> count;

        for (int i = 0; i < count; i++)
        {
            int tempNum;
            string tempFirst;
            string tempLast;
            char temp[250];
            string mailing;
            long long phone;
            string CCNum;
            double tempBalanceDue;
            string pin;

            file >> tempNum;
            file >> tempFirst;
            file >> tempLast;
            file.ignore();
            file.getline(temp, 250);
            mailing = static_cast<string>(temp);
            file >> phone;
            file >> CCNum;
            file >> pin;
            file >> tempBalanceDue;

            Customer tempCust;
            tempCust.setCust(tempFirst, tempLast, mailing, phone, CCNum, pin, tempNum, tempBalanceDue);
            custs.push_back(tempCust);
        }

        file.close();
    }
    catch(exception &e)
    {
        cout << e.what() << " Unable to open custFile.txt" << endl;
        file.clear();
        system("pause");
    }

    try
    {
        int count = 0;
        file.open("roomFile.txt");

        if (!file.eof())
            file >> count;

        for (int i = 0; i < count; i++)
        {
            int roomNo;
            double cost;
            bool smoking, twobeds, suite;

            file >> roomNo;
            file >> cost;
            file >> smoking;
            file >> twobeds;
            file >> suite;

            Room temp(roomNo, cost, twobeds, smoking, suite);
            rooms.push_back(temp);

        }
        file.close();
    }
    catch(exception &e)
    {
        cout << e.what() << " Unable to open roomFile.txt" << endl;
        file.clear();
        system("pause");
    }

    try
    {
        int count = 0;
        file.open("reservationFile.txt");

        if (!file.eof())
            file >> count;

        for (int i = 0; i < count; i++)
        {
            int custNum;
            int reservNo;
            int roomNo;
            double cost;
            int day1, month1, year1, day2, month2, year2;

            file >> custNum;
            file >> reservNo;
            file >> roomNo;
            file >> cost;
            file >> day1 >> month1 >> year1;
            file >> day2 >> month2 >> year2;

            Reservation temp(custNum, roomNo, reservNo, cost, day1, month1, year1, day2, month2, year2);
            reservations.push_back(temp);

        }
        file.close();
    }
    catch(exception &e)
    {
        cout << e.what() << " Unable to open reservationFile.txt" << endl;
        file.clear();
        system("pause");
    }
}

Never mind, I figured it out

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.