www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/10/14:41:27

From: kagel AT quasar DOT bloomberg DOT com
Date: Mon, 10 Feb 1997 14:21:43 -0500
Message-Id: <9702101921.AA01209@quasar.bloomberg.com >
To: mert0407 AT sable DOT ox DOT ac DOT uk
Cc: djgpp AT delorie DOT com
In-Reply-To: <32fd22eb.29598800@news.ox.ac.uk> (mert0407@sable.ox.ac.uk)
Subject: Re: Error or question.
Reply-To: kagel AT dg1 DOT bloomberg DOT com

   From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot)
   Newsgroups: comp.os.msdos.djgpp
   Date: Sun, 09 Feb 1997 01:16:17 GMT

   On Sat, 8 Feb 1997 22:31:40 GMT, ethan DOT jacobs AT juno DOT com (Ethan L
   Jacobs) wrote:

   >	I have a book that says fscanf is supposed to return EOF. In
   >DJGPP it returns NULL. Is that an error or is it supposed to be there?

   I'm not sure what you're referring to here... fscanf returns the
   number of items successfully scanned (quote from libc docs) or, which
   isn't stated, EOF if it reaches the end of the file. 

   Note that here NULL==0, so if it returns 0 meaning no items scanned
   you could be reading this as a NULL.

From the UNIX man page for fscanf:

   Errors
       These routines return the number of successfully matched and assigned
       input items; this number can be zero in the event of an early
       matching failure between an input character and the control string.
       If the input ends before the first matching failure or conversion,
       EOF is returned.

K&R 2d says the same.

-- 
Art S. Kagel, kagel AT quasar DOT bloomberg DOT com

A proverb is no proverb to you 'till life has illustrated it.  -- John Keats

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019