問題は、ループが実行されるたびにプログラムがそのままファイルを書き換え、出力ファイルにのみ残るため、出力ファイルを1
1行目、2行目などにどのようにするかです。2
9
#include <fstream>
using namespace std;
void function (int i)
{
ofstream output("result.out");
output << i << endl;
output.close();
}
int main()
{
for (int i=1; i<10; i++)
{
function(i);
}
return 0;
}