At what point is the actual recording of information on the disc?
There is, for example, the following code:
std::ofstream file("somefile"); file << "Hello, world!\n"; std::flush(file); If immediately after executing the line std::flush(file) I cut down electricity, then what are the chances when it is turned on to see in the file Hello, World! ? If the chance is not 100%, then how to bring it to the desired guarantee result? Does the OS (Linux / Windows) have any way to make sure that the information on the disk has entered? How is this situation handled in databases during transactions?
UPD: Will the line be written to the file if the program crashes right after std::flush(file) ?