I have a problem.
My program is prompting the user for a file address like this:
// ...
string address;
cout << "Enter file address:\n";
cin >> address;
file.open(address);
// ...
But this is causing me an error. Anybody has any suggestions?
Thanks!
Printable View
I have a problem.
My program is prompting the user for a file address like this:
// ...
string address;
cout << "Enter file address:\n";
cin >> address;
file.open(address);
// ...
But this is causing me an error. Anybody has any suggestions?
Thanks!
The open() function takes a const char*, not a std::string.
Secondly, you need to specify the mode to open the file in where I put /* other arguments */.Code:file.open(address.c_str(), /* other arguments */);
Regards,
Paul McKenzie