Search code examples
clinuxio

Does `close()` flush buffered output data?


fclose() flushes buffered output data.

Does close() also flush buffered output data?


Solution

  • There are no buffers in a C program associated with an open file descriptor, and so no buffered data to speak about.

    Your OS may or may not have some buffers associated with an open file descriptor (or with a device on which the corresponding file resides), depending on the nature of the file. These are normally invisible at the application program level, and not affected by close.