Dec 21, 2012 at 9:59pm UTC
I am trying to get the first line of the file and I'm not getting any part of the file.
using namespace std;
int main ()
cout << "Enter password file: ";
getline( cin, filename );
fstream file( filename.c_str() );
cerr << "Unable to Open Input File: "
<< filename << "\n";
Dec 21, 2012 at 10:04pm UTC
The file stream can not read anything from the file because it has yet to receive the name of the file that is to be opened. I've also noticed that both of the objects created have the same identifier (file and file). The code posted below should correctly perform the given task.
2 3 4 5 6 7 8 9 10
cerr << "Error: Unable to open file.\n";
getline(file, line1, '\n');
Last edited on
Dec 21, 2012 at 10:10pm UTC
Dec 21, 2012 at 10:23pm UTC
How would i get only the second line of the file?