[RESOLVED] Try, Catch Problem
I have a try catch block that should, when it doesn't work, display a message saying the file couldn't be found. Unfortunately, all it does is just go back to asking for a file. Here's the code, why won't it do the cout in the catch block?
Code:
bool readArray (double x [], int &n)
{
int i;
char filename[51];
ifstream inputFile;
bool success;
cout << "Enter filename (and path, if needed):" << endl;
cin.getline(filename, 51);
cout << endl << endl;
try
{
inputFile.open(filename);
}
catch(...)
{
cout << "Error opening file." << endl << endl;
success = false;
}
if (success != false)
{
//read file stuff
}
return success;
}