I have created a procedure, exitFailure() that is invoked if a file doesn't exist:
int exitFailure()
{//start exitFailure()
printf("Failure, hit any key to exit and press enter.\n");
scanf("%d", &counterx);
return 1;
}//end exitFailure()
Below is the snippit of code that invokes exitFailure()
inFile.open(inputFilename, ios::in);
if (!inFile)
{
cerr << "Can't open input file " << inputFilename << endl;
exitFailure();
return 1;
}
If the file doesn't exist, the program exits. Please note that return 1 is included in the procedure, as well as the snippit of code.
HOWEVER, if I remove return 1 from the snippit of code, run the program and enter in a filename that doesn't exist, the program continues to execute. It is as if my program is ignoring the return 1 from procedure exitFailure().
Please advise