fclose closes a C stream and flushes its buffered output to its destination. Closing is therefore more than ending access: it ensures pending output is delivered. section 8.3.3
Keep these practical distinctions in view:
- Use fclose when the stream is no longer needed and should be closed after its buffered output has been flushed. section 8.3.2 section 8.3.3
- Use fflush when output must reach its destination immediately but the stream must remain open. section 8.3.3
- Remember that text output is commonly buffered, so visible terminal output may depend on line buffering or an explicit flush. section 8.3.3
Flushing buffered output
A delayed-output demonstration writes dots to stdout and conditionally calls fflush(stdout). That makes the difference clear: fflush exposes output while the stream remains active; fclose provides the final flush when the stream is closed. section 8.3.3
