www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/17/15:21:49

From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: fread/fwite return value
Date: Wed, 16 Jul 1997 14:59:05 -0400
Organization: Cornell University
Lines: 26
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <33CD19F9.4FF2@cornell.edu>
References: <422564D6 DOT 005C61DE DOT 00 AT aks DOT com>
NNTP-Posting-Host: 128
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

eyal DOT ben-david AT aks DOT com wrote:
> 
> On 7/16/97 6:05:33 PM heretic wrote:
> 
> >So, I wanted to have error checking and I wrote something like
> >
> > if ( fread(blah,blah,blah) == -1 )
> > {
> >    oh_no_error ();
> > }
> >
> >But compiler warned that I am comparing unsigned and signed. And it
> >was right: size_t is unsigned long! Anyone knows how fread or fwrite
> >can return -1 on error while its return value is unsigned?
> >
> cast .  now it is  0xFFFFFFFF.
> 
> if (fread (...) == (size_t) -1)
> {
>     .....
> }

and could you tell me how on earth you would distinguish that from a
valid number of bytes read by fread???

  -- Sinan

- Raw text -


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