Mail Archives: djgpp/1997/07/16/09:15:31
hi there
I've noticed a kind of anomaly while writing a program using
fwrite/fread functions. First take a look at library reference:
size_t fread(void *_ptr, size_t _size, size_t _nelem, FILE *_stream);
(...)
Return value
============
The number of items of size SIZE read, or -1 on error.
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?
---------------------------------------
With heretic's greeting
http://www.polbox.com/h/heretic
---------------------------------------
- Raw text -