It depends. On most platforms, file IO is cached hence the fflush()
call exists to write cached data to disk - in that respect, the answer to your first question is (usually) "yes", and your second "no". That said, it's not guaranteed to be that way by any stretch of the imagination for any particular platform - generally, the standards only specify the interface for such functions, not their implementation. Also, its quite possible that calling fwrite()
will cause an implicit flush if the cache becomes "full", in which case calling fwrite()
may in fact trigger file IO - especially if calling fwrite()
with large amounts of data.
BUFSIZ
, as defined in stdio.h, though of course callers shouldn't need that information.setbuf
may be used to control the size on some systems. – Finnougrian