![]() |
| | #1 |
| Registered User Join Date: Mar 2002
Posts: 12
| Code: cin>>input_file;
fin.open(input_file);
while (fin.fail())
{
fin.close();
cout<<"Error opening input file. Did you input the wrong name or path?\n";
cout<<"\nEnter the name of the text file: \n\n";
cin>>input_file;
fin.open(input_file);
}
Is there a better way? |
| jpchand is offline | |
| | #2 |
| root Join Date: Sep 2003
Posts: 232
| >Is there a better way? Code: while (!cin.getline(filename) || !fin.open(filename) cerr<<File open failure, try again...\n"; |
| twm is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need some help with C program writing | The_PC_Gamer | C Programming | 9 | 02-12-2008 09:12 PM |
| for loop with sort issues | redmondtab | C Programming | 10 | 10-09-2006 10:36 AM |
| vectors and user input | Chaplin27 | C++ Programming | 6 | 01-17-2005 10:23 AM |
| comparing user input | lambs4 | C Programming | 5 | 12-15-2002 10:28 AM |
| Format User Input When using strings | Unregistered | C Programming | 4 | 03-08-2002 03:59 AM |