Re: Question regarding fwrite() and fflush()

Liste des GroupesRevenir à cl c  
Sujet : Re: Question regarding fwrite() and fflush()
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.c
Date : 25. Jun 2024, 22:55:47
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <86jziceo8c.fsf@linuxsc.com>
References : 1
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:

In a recent reply here, I posted some code that used fwrite() to write
binary data to a file.  One version of this code used mmap() to access
this binary data in-situ, and I wonder if I should have called fflush()
before calling mmap().
>
I understand the where to use fflush() on standard text formatted output
(where you use fprintf(), etc to externalize the output), but I don't see
anything my copies of either the ISO C or POSIX standards that say that
I /should/ use fflush(), but neither do I see anything that says I /need
not/ use fflush().
>
So, wiser and more experienced minds, should I use fflush() in this case
or not?

Yes, do use fflush().

In the alternative, do a setbuf( file, 0 ) so that 'file' is
unbuffered.

Date Sujet#  Auteur
25 Jun 24 * Question regarding fwrite() and fflush()4Lew Pitcher
25 Jun 24 +* Re: Question regarding fwrite() and fflush()2Tim Rentsch
25 Jun 24 i`- Re: Question regarding fwrite() and fflush()1Lew Pitcher
26 Jun 24 `- Re: Question regarding fwrite() and fflush()1Lawrence D'Oliveiro

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal