File I/O problem

Pages: 12
Maybe, try opening it like this:
ofstream output_file ("output.txt", ios::out|ios::app);
This way is cannot possibly overwrite the data.

ios::app means append, by the way: http://www.cplusplus.com/reference/iostream/ofstream/open/
Last edited on
Thanks for the solution L B.

unfortunately after using:

ofstream output_file ("output.txt", ios::out|ios::app);

I was still only able to get 4 values in the output file.

the values were 1 26 88 and 4.

however the last values in the program were not a= 26 or b =88... they were a=35 and b=95.

it turns out that 22/88 was the first problem displayed in the prompt by the program... so the function is storing the correct a,b, and operator into the output file however it is not moving past those first initial values.

EDIT: I got the values to display by moving the output_file.close() outside of the while loop.
Last edited on
Topic archived. No new replies allowed.
Pages: 12