Hey,
I wish to output the results of my program onto an output file. Hence I create an ofstream object as follows;
ofstream output ("Output.txt");
Then I print the value for the initial conditions of my problem as,
printf("\n%f", t);
Now, whenever i comment out the declaration of ofstream object, the initial value of t printed is correct (0.0). when i uncomment it, I get a value printed (8.546) which is apparently junk. No other changes are made to the code.
I do not know the source of this error. Also, the results are not getting printed into the output file.
The printf call writes to a FILE *, in this case to standard out (stdout). Streams do not work with printf -- you should use one of the functions of ofstream to write to your file.