Hi,
sorry forgot to close the endtag......in previous post!!
the prog. should
1)take the input file from the user,
2)if file does not exist ,display error message
3) if the user types in correct file name ,file should be opened, and database populated
4) if user wants to exit press -1.....
In my code its becoming exactly opposite ,if I type -1 ,file is opened ,if I type "names.txt", error message is displayed.....Why???
can anyone let me know where I am going wrong....
thanks a lot...........
Code:
int numb = 0;
string file = " ";
int latID=0;
ifstream inputFile("names.txt", ios::in );
ofstream outputFile;
cout<<"Enter the file (-1 to end)"<<endl;
cout<<"reading the file........"<<endl;
cin.geline(file, 100, '\n');
while(file !="-1")
{
inputFile.open(file.c_str(), ios::in);
if(inputFile.fail())
{
cout << "\n\n\t\t\..........***Input file does not exist*****"<<endl;
inputFile.clear();
cout<<"Enter the file (-1 to end)"<<endl;
cin.geline(file, 100, '\n');
inputFile.open(file.c_str(), ios::in);
}
}
adatabase(database,numb);
displayMainMenu();
getMenuOption(database,numb);
return 0;
}