dimanche 8 mars 2015

File Path Name and User Input


I am trying to have the user input the file path of a file to be read by my program. However, when I try to compile the code, it errors, with the following error: no matching function to call to 'std::basic_ifstream::open(std::string&)'. The code works correctly with no errors when I directly enter the file instead of using getline or cin. I don't know what is the problem. Any suggestions?



int main()
{
ifstream input_file;
string file_name;
cout<< "Please input file path to PostFix arithmetic expressions file\n";
getline(cin, file_name);
input_file.open(file_name);
read_and_evaluate(input_file);
}



Aucun commentaire:

Enregistrer un commentaire