[try Beta version]
Not logged in

 
Cannot write to file.

Apr 6, 2014 at 6:38am
Hi guys. The for loop runs 100% perfectly except its not writing the values to the file.(Yes I know its meant to be 'outfile' but im writing out to two different files so I thought that I might not be able to use the same object to write to two files. Would it make a difference?

Any help will be greatly appreaciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
       ofstream outHour;
     outHour.open("byhour.txt");

    for(coloumns=0; p>=3600; coloumns++)
    {
        i++;


        outHour << i << accumulatedPower/3600000 << endl;

        accumulatedPower=0;
        p=0;
    }
Apr 6, 2014 at 7:42am
that loops seems to be an infinite one
Apr 6, 2014 at 7:53am
no because p gets set back to zero. therefore everytime p reaches 3600 the loop runs. its just not writing to the file
Apr 6, 2014 at 8:52am
can you post the whole code ? or at least the codes outside that loop
Apr 6, 2014 at 8:53am
1
2
3
4
5
6
#include <iostream>
#include <vector>
#include <fstream>
#include <cstdlib>
#in
Last edited on Apr 6, 2014 at 6:26pm
Topic archived. No new replies allowed.