I have developed a code here that opens the input file. If the file does not open, I want it to prompt "file not open." The problem in code is that I have created an input file that has data on it and I even have it open during the runtime. I'm still getting an output on the console saying "The file is not open," especially when it is.
1 2 3 4 5 6 7 8 9 10 11 12 13
//make a file for input
void make_input(ifstream &fin,string &filename)
{
cout<<"Input File: ";
getline(cin,filename);
//Open the file
fin.open(filename);
//if file doesnt open
if(!fin)
cout<<"\nFile not open";
}