Why doesn't this code work? The if statement is always turning out to be true.
Code:#include <iostream> #include <fstream> using namespace std; int main() { fstream file; char name[33]; cout << "Enter the name of the file you wish to open" << endl; cin.getline(name, 33); file.open(name); if (file.fail()) cout << "Unable to open file" << endl; file.close(); return 0; }