I am trying to figure out why my function to open a file is failing this autograder I submit my homework into. What type of input would fail here, I can't think of anything else?
Code:
bool openFile(ifstream& ins)
{
char fileName[256];
cout << "Enter board filename: ";
cin.getline(fileName,256);
cout << endl << fileName << endl;
ins.open(fileName);
if(!ins) {
ins.clear();
cout<<"Error opening file"<<endl;
return false;
}
return true;
}
Here is output from the 'Autograder' of what my program's output is, and what the correct output is supposed to be (and I do not know what is in the file they use for the input)
Autograder output:
*******************************************
***** *****
***** Your output is: *****
***** *****
*******************************************
Testing function openFile
Enter board filename:
test.txt
1
Enter board filename:
not a fileName
Error opening file
0
*******************************************
***** *****
***** Correct Output *****
***** *****
*******************************************
Testing function openFile
Enter board filename:
1
Enter board filename:
Error opening file
0