ifstream arguments - C++
I Declared: std::string input_file="1.txt";开发者_StackOverflow
then I tried to do this command:
static ifstream myfile (input_file);
and I get the error: no matching function for call to : std::basic_ifstream<char>::basic_ifstream(std::string&)
Try:
static ifstream myfile(input_file.c_str());
For some reason, the ifstream
constructor doesn't accept an std::string
.
精彩评论