开发者

ifstream arguments - C++

开发者 https://www.devze.com 2023-04-03 03:53 出处:网络
I Declared: std::string input_file=\"1.txt\";开发者_StackOverflow then I tried to do this command:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号