Reputation: 125
so I'm a newbie at C++, and I've been poking around on the internet on how to do this, and so far I have this:
void includeFile(string name){
ifstream ifs;
ifs.open(name);
string commands;
while (getline(ifs,commands)){
commandReader(ifs);
}
ifs.close();
}
(commandReader is a function that takes an istream)
When I try to compile, I get the error "no matching function for call" and then gives me the line number for the ifs.open(name) line. I've included fstream, so not sure why it's doing this
Upvotes: 0
Views: 56
Reputation: 6488
As @chris pointed out, pre-C++11, ifs.open
expects a char*
, not an std::string
. Try ifs.open(name.c_str())
.
Upvotes: 0
Reputation: 125
Sorry, never mind; found the answer right after I posted this. The solution was to have name.c_string() as the parameter instead, as string support was only added in c++11
Upvotes: 1