🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fr.comp.lang.c
Article #15167

Re: fwrite et setvbuf

#15167
From: Pierre Habouzit
Date: Sat, 08 Oct 2005 17:42
31 lines
2353 bytes
Emmanuel wrote:

> Pierre Habouzit a �crit :
>> Je fais un programme qui n'arr�te pas d'�crire des structures binaires
>> dans un fichier. Ces structures font 24 octets, et je m'�tais laiss� dire
>> que fwrite �tait bufferis�.
>> 
>> Apres un peu de recherche, j'ai r�alis� que fwrite bufferisait sur '\n'
>> par d�taut et que donc il fallait que je fasse un :
>> 
>>     setvbuf(my_file, NULL, _IOFBF, BUFSIZ);
> 
> Si tu passes un NULL, je ne vois pas bien dans quoi il va bufferiser...
> Tu as de la chance que �a ne t'ai pas explos� � la tronche...
> 
> Je n'ai jamais utilis� cette fonction, mais il me semble �vident
--- de faire comme �a:
+++ que lire la doc est bien

  Except  for unbuffered files, the buf argument should point to a
  buffer at least size bytes long; this buffer will be used instead of
  the  current buffer.  If the argument buf is NULL, only the mode is
  affected; a new buffer will be allocated on the next read or write
  operation. The setvbuf function may only be used after opening a stream
  and before any other operations have been performed on it.


-- 
�O�  Pierre Habouzit
��O                                                madcoder@debian.org
OOO                                                http://www.madism.org
Technical Details
Message-ID: <43480508$0$9731$626a14ce@news.free.fr>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!infeed-1.proxad.net!news18-e.free.fr!not-for-mail
References: <4347c389$0$14664$626a14ce@news.free.fr> <4347d729$0$4330$626a54ce@news.free.fr>

Show Full Headers
Complete Article Headers
X-Google-Thread: f9822,e69a4cd47d957512
X-Google-Attributes: gidf9822,public
X-Google-Language: FRENCH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!infeed-1.proxad.net!news18-e.free.fr!not-for-mail
Message-ID: <43480508$0$9731$626a14ce@news.free.fr>
From: Pierre Habouzit <madcoder@debian.org>
Subject: Re: fwrite et setvbuf
Newsgroups: fr.comp.lang.c
Date: Sat, 08 Oct 2005 19:42:38 +0200
References: <4347c389$0$14664$626a14ce@news.free.fr> <4347d729$0$4330$626a54ce@news.free.fr>
User-Agent: KNode/0.9.2
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8Bit
X-Face: $(^e[V4D-[`f2EmMGz@fgWK!e.B~2g.{08lKPU(nc1J~z\4B>*JEVq:E]7G-\6$Ycr4<;Z!|VY6Grt]+RsS$IMV)f>2)M="tY:ZPcU;&%it2D81X^kNya0=L]"vZmLP+UmKhgq+u*\.dJ8G!N&=EvlD
Lines: 31
Organization: Guest of ProXad - France
NNTP-Posting-Date: 08 Oct 2005 19:42:32 MEST
NNTP-Posting-Host: 82.225.205.10
X-Trace: 1128793352 news18-e.free.fr 9731 82.225.205.10:49724
X-Complaints-To: abuse@proxad.net