Cannot write this loop to a file.

Hi guys, im having serious trouble writing the outputs of this loop into a file. Any help will be much appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
        accumulatedPower= totalPower;
    p = totalTime;

    ofstream outFile;
    outFile.open("byhour.txt");


    if(p  == 3600)
    {
        coloumns++;
        outFile << coloumns << "\t" << accumulatedPower << endl;

        accumulatedPower=0;
        p=0;


    }
        cout << "P value" << p << endl;
        cout << "accumulated power" << accumulatedPower << endl;
        cout << "Coloumns" << coloumns << endl;
Last edited on
What loop?
Sorry, I mean if statement.

I want the if statement to run when p=3600 and then p must reset to 0 and run again until it =3600.
And at the same time I want them to write out to a file.
Can you write to a file in an if statement?
Topic archived. No new replies allowed.