Deutsch English Français Italiano |
<86jziceo8c.fsf@linuxsc.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!2.eu.feeder.erje.net!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch <tr.17687@z991.linuxsc.com> Newsgroups: comp.lang.c Subject: Re: Question regarding fwrite() and fflush() Date: Tue, 25 Jun 2024 13:55:47 -0700 Organization: A noiseless patient Spider Lines: 20 Message-ID: <86jziceo8c.fsf@linuxsc.com> References: <v5f33f$1l548$3@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Tue, 25 Jun 2024 22:55:47 +0200 (CEST) Injection-Info: dont-email.me; posting-host="df40ff635303007d0403e8efc320894e"; logging-data="1821636"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kzXmfn5Hcvr19xEbff/mvjaxAyFWwa8Y=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:DT/ktxlL2ahWvig1bdvtqUfpi7A= sha1:LWZnyMJmnmsOCqHep4E36nykbDw= Bytes: 1827 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.