I want the user to enter then name of the file to open so i did this basicly
cin>>name; /* this isnt real code */
ifstream ifile;
ifile.open(name)
blah
but it doesnt work...how would I do this?
I want the user to enter then name of the file to open so i did this basicly
cin>>name; /* this isnt real code */
ifstream ifile;
ifile.open(name)
blah
but it doesnt work...how would I do this?
+++
++
+ Sekti
++
+++
char filename[80];
cin.getline(filename,79,'\n');
ifstream input;
input.open(filename);
if( input.fail() )
{
cout << "Error with file " << filename << endl;
}
else
{
//do whatever you want with the file
}