delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/14/13:19:31

From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp,comp.lang.c++
Subject: Re: Reading binary files
Date: Fri, 13 Jun 1997 10:13:51 -0400
Organization: Cornell University http://www.cornell.edu
Lines: 26
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <33A1559F.7F98@cornell.edu>
References: <33a13a3a DOT 2140316 AT supernews DOT scsn DOT net>
Reply-To: asu1 AT cornell DOT edu
NNTP-Posting-Host: cu-dialup-0050.cit.cornell.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Chris wrote:
> 
> When reading in binary files, I need to know how to stop when reaching
> the EOF.
> 
this is waht the ANSI specs say about fread:

"The fread function returns the number of elements successfully read,
which may be less than nmemb if a read error or EOF is encountered. If
size or nmemb is zero, than the contents of the array and the state of
the stream remain unchanged."

Use this information and the standard ferror function. i would also
recommend reading the C FAQ and posting basic C questions to comp.lang.c
or comp.lang.c.moderated.
-- 
   Sinan
 
*******************************************************************
 A. Sinan Unur                                WWWWWW
                                              |--O+O
 mailto:sinan DOT unur AT cornell DOT edu                C   ^ 
 http://www.people.cornell.edu/pages/asu1/     \  ~/ 

Unsolicited e-mail is _not_ welcome, and will be billed for.
*******************************************************************

- Raw text -


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