Need help opening a file from user input.

I get an error that says, "no matching function." On the line with the function.

#include <iostream>
#include <fstream>

using namespace std;

int main(){
string name;
ifstream file;

cout << "Enter the file name: ";
getline(cin, name);;

return 0;
Last edited on
That function accepts a string parameter only from C++11 onwards. If you have an old compiler, get a new one, or use the other version of the function, that accepts a char* (; ) .

This is the year 2018, and many good modern compilers are free. You should get one.
Last edited on
I am using c++11 and i still get that error message for some reason. But I've tried it with .c_str() and now it works fine.

thanks for the help.
Registered users can post here. Sign in or register to post.