-
September 5th, 2009, 11:37 AM
#1
file.open(address); // ERROR
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!
-
September 5th, 2009, 12:57 PM
#2
Re: file.open(address); // ERROR
The open() function takes a const char*, not a std::string.
Code:
file.open(address.c_str(), /* other arguments */);
Secondly, you need to specify the mode to open the file in where I put /* other arguments */.
Regards,
Paul McKenzie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|