0
파일을 동적으로 만들려고하는데 fstream을 사용할 방법이없는 것처럼 보입니다. 실제로 어떤 것이 있습니까?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();
}
}
'(char) i + "sample_file.txt"'당신이 생각하는대로하지 않습니다. 이것은 Java/C#이 아닌 C++입니다. – heavyd