Hi everyone:
I have written c++ code for performing a calculation. I know how to output my results to a file (example below).
What I want to do now is include a loop in my calculation, so that each loop represents a new time step. My problem is, I don't want to make a new output/results file for each new time step. I want one results file, where results are concatenated/added into the file for each new time step.
Is this possible? If so, I would very much appreciate an example! Thanks a lot.
ofstream xOut;
xOut.open ("x.txt");
for(int i = 0; i < d_xi; i++)
{
for(int j = 0; j < d_xi; j++)
{
xOut << gridPtMatX(i,j) << " ";
}
xOut << endl;
}
xOut.close();
I have written c++ code for performing a calculation. I know how to output my results to a file (example below).
What I want to do now is include a loop in my calculation, so that each loop represents a new time step. My problem is, I don't want to make a new output/results file for each new time step. I want one results file, where results are concatenated/added into the file for each new time step.
Is this possible? If so, I would very much appreciate an example! Thanks a lot.
ofstream xOut;
xOut.open ("x.txt");
for(int i = 0; i < d_xi; i++)
{
for(int j = 0; j < d_xi; j++)
{
xOut << gridPtMatX(i,j) << " ";
}
xOut << endl;
}
xOut.close();