Hi,

I'm working my way through the book C++ Without Fear, after reading the recommendation for it on this site. However, one of the programs doesn't work. Basically it prompts the user to enter a filename, then it creates a file input stream. It then checks to see if that file input stream has a NULL value before continuing. However, for some reason, the check always comes back negative.

Can anyone help me out? Here is the code. Running the program should make it pretty obvious where the problem is because it seems like it's probably something simple. Thanks guys.

Code:
#include <iostream>
#include <fstream>
using namespace std;

int main() {
    int c;   // input character
    int i;   // loop counter
    char filename[81];
    char input_line[81];

    cout << "Enter a file name and press ENTER: ";
    cin.getline(filename, 80);

    ifstream file_in(filename);

    if (! file_in) {
        cout << "File " << filename << " could not be opened.";
        return -1;
    }

    while (1) {
        for (i = 1; i <= 24 && ! file_in.eof(); i++) {
            file_in.getline(input_line, 80);
            cout << input_line << endl;
        }
        if (file_in.eof())
            break;
        cout << "More? (Press 'Q' and ENTER to quit.)";
        cin.getline(input_line, 80);
        c = input_line[0];
        if (c == 'Q' || c == 'q')
            break;
    }
    return 0;
}