Printing series of information to a file.

Hi, I am trying to print a series of variables to a file. I know what is wrong, I believe anyways, it is overwriting the files, or stopping, and not printing the whole thing. Here is the code.
1
2
3
4
5
6
7
8
9
ofstream Time;
for (int c = 0; c < 6; c++)
    {
        Time.open ("Time.txt");
        Time << day[c] << " " << fixed << showpoint << setprecision(2) << abs (time1[c] - time2[c]) << endl;
    }
    Time.close();
}

What is the best way to get it to print the whole series to a file? Thanks.
Try moving the Time.open outside of the for loop.
That does work! Thanks!
Last edited on
Topic archived. No new replies allowed.