C++ open() fails for no apparant reason
- by jondoe
The following code:
char filename[64];
ifstream input;
cout << "Please enter the filename: " << endl;
cin >> filename;
input.open(filename);
if (!input.is_open())
{
cout << "Opening file " << filename << " failed." << endl;
exit(1);
}
fails, it enters the if() and exits. What could possibly be the cause for this? I'm using Microsoft Visual C++. When I hardcoded the filename as a constant it instead ended up garbled:
http://pici.se/pictures/CNQEnwhgo.png
Suggestions?