title: How to wait for cpp fstream to finish writing before moving on?
body: <p>I have a c++ driver that contains a do-while loop.  Inside this loop, I have data written to disk every so many iterations by a member function of a class.  The funny thing is, the function seems to write almost all of the data for the nth time it is called, but then write the rest the (n+1)th time.  It then proceeds to write some of the (n+1)th data and stops writing pre-maturely, etc...</p>
  
  <p>Forgive me for possibly speaking imprecisely here, but I suspect that the filestream is storing the data and does not have enough time to finish writing it to disk (there is a lot of data to write each time the function is called).  It then writes what was left over from the last time it was used and tries to move on to what it was supposed to currently be doing.</p>
  
  <p>Has anyone encountered a similar problem?  Is there a way to keep a program from moving on before a fstream is completely done writing?</p>