About file stream

When i write to a file and close it does it immediately writes to a disk or do i have to Sleep() some time before i can use it?

1
2
3
4
ofstream out("file");
out.write(....);
out.close();
...right after close i use that file

Closing a stream flushes all application buffers. Whether and when the file actually gets written is up to the OS, but it's guaranteed that if you try to read the file, it'll behave as if it had been written.
This is not necessarily the case if there suddenly was a power failure or a system crash.
Topic archived. No new replies allowed.