Sender: crough45 AT amc DOT de Message-Id: <97Jul17.140456gmt+0100.16641@internet01.amc.de> Date: Thu, 17 Jul 1997 13:09:02 +0100 From: Chris Croughton Mime-Version: 1.0 To: asu1 AT cornell DOT edu Cc: djgpp AT delorie DOT com Subject: Re: fread/fwite return value Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk A. Sinan Unur wrote: > while( fread(&c, 1, 1, f) ) > printf("%c", c); While this is correct according to ANSI C, I prefer to do: while( fread(&c, 1, 1, f) > 0 ) printf("%c", c); just in case it returns a negative value (some Unix systems have done that to me in the past). Defensive programming. OK, paranoid programming ... (I fail to see, however, why using fread is any better than using getc; it's a lot less efficient for a single character in most implementations...) Chris C