User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 391,588 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,634 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 3060 | Replies: 2
Reply
Join Date: Nov 2004
Posts: 6
Reputation: kisseric is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kisseric kisseric is offline Offline
Newbie Poster

Error message when trying to open an external file in C++ program

  #1  
Nov 18th, 2004
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,646
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 191
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Error message when trying to open an external file in C++ program

  #2  
Nov 18th, 2004
post your code properly using code tags rather than in huge coloured fonts and someone may bother to look at it and succeed without getting a headache.
Reply With Quote  
Join Date: Nov 2004
Posts: 6
Reputation: kisseric is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kisseric kisseric is offline Offline
Newbie Poster

Re: Error message when trying to open an external file in C++ program

  #3  
Nov 23rd, 2004
sorry, i was not intending to cause headaches for anyone. i was desperate for help.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C++ Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 11:08 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC