有什么方法可以访问吗? 有文本文件,如 john.txt micheal.txt james.txt ....
我可以用这段代码访问它们:
ifstream file1( "james.txt", ios::in );
我可以打开这样的文件吗?
string name = "james"; ifstream file1( name, ios::in )
最佳答案
也许你可以尝试这样的事情:
ifstream file1((name + ".txt").c_str(), ios::in);
关于c++ - 使用变量访问文本文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17759399/