You need to close the output file before opening the input file because some of the data has not been flushed to disk yet.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
The binary flag prevents streams from interpreting any of the binary characters (whose character values outside the range of normal printable characters). In normal text files the "\r\n" characters (ms-windows) in the file are used to indicate end-of-line for functions such as getline(). Binary files may also by coincidence have the "\r\n" pair, so the binary flag is used to prevent any interpretion by fstream.
>>and other flags like ios::app are used instead
You can use both flags at the same time by using the or operator | to combine them
ofstream out("test.data", ios::binary | ios::app);
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343