我正在尝试动态创建文件,fstream 似乎没有办法。真的有吗?
#include <iostream>
#include <fstream>
using namespace std;
int main () {
for (int i = 0; i<2; ++i){
std::ofstream outfile
outfile.open ((char)i+"sample_file.txt"); // something like this. numbers appended to the filename
outfile << i;
outfile.close();
}
}