Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flushing only the written parts of a buffer to a file (using fstream)

Status
Not open for further replies.

nexius

Programmer
Jul 8, 2000
109
CA
Hi

I'm using fstream to log some messages to a file and there are some cases where it's important to flush the buffer to the file instead of letting it flush when the buffer is full. This works, it's just that along with the written parts of the buffer, it writes all this garbage to the file.

Is there an easy way to prevent this?

I'm using fstream btw

-neXius
 
It's impossible situation, flush() can't write any garbage. But Windows (NT++) may hold a real write disk operation none the less...
Don't forget: disk file space allocation unit is not a byte, OS may write a whole sector but it sets true file length in any case...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top