I need help ladies and gentlemen, I am writing a program that validates ISBN numbers both from file and from console input. However my program is unable to open the file even though I have it in my Debug folder. Here is a piece of my code. I need help urgently;
int main()
{
ifstream fin;
int choice; //selected option from the menu
fin.open(inData);
char line[100];
cout<<" ISBN VALIDATOR"<<endl;
cout<<" ****************"<<endl;
do
{
//the printing of the menu
cout<<endl<<"MENU OPTIONS:"<<endl;
cout<<"1. READ ISBNs FROM CONSOLE"<<endl;
cout<<"2. READ ISBNs FROM FILE (isbntest.txt)"<<endl;
cout<<"3. EXIT"<<endl;
cout<<"PLEASE ENTER YOUR CHOICE:";
cin>>choice; //read the user choice
switch(choice)
{
case 1:
cout<<"PLEASE ENTER ISBN NUMBER:";
cin>>line;
//showResult(line); //reads the ISBN from the console and check it
break;
case 2:
char n;
ifstream fin;
fin.open("isbntest.txt");
//ifstream fin(inData); //opens the file isbntest.txt
if (fin.is_open()) //if the opening succeeded
{
fin>>n; //reads the number of tests
for(int i=0;i<n;i++)
{
fin>>line; //reads each ISBN
showResult(line); //and check if is correct
}
fin.close();
}
else
cout<<"COULD NOT OPEN THE FILE <isbntest.txt>."<<endl;
//break;
}//switch
}//do
while(choice!=3); //repeat printing the menu until the user chooses option 3
return 0;
}//main