flush on close()?

P

Philipp

Hello, just a simple question:
Does the close() method of an ofstream object always flush the buffer?

Thanks for answers.
Phil
 
T

Timothy Madden

Philipp said:
Hello, just a simple question:
Does the close() method of an ofstream object always flush the buffer?

Thanks for answers.
Phil

Of course it does ! No written characters or data are lost.

The operating system might not follow this same ideea. It is free to decide
that the file is on a fixed drive that won't go anywhere and that caching it
until the next disk write is worthy

Timothy Madden
Romania
 
M

Mike Wahler

Philipp said:
Hello, just a simple question:
Does the close() method of an ofstream object always flush the buffer?

No, not always, but when needed (e.g. the last write operation
might have already caused a flush). You can be assured that
(barring errors) everything has been written after closing
an output stream.

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,176
Messages
2,570,950
Members
47,503
Latest member
supremedee

Latest Threads

Top