I'm trying to check when fread()
raises an error, so I use ferror()
.
chunk = fread(buf, 1, 100, file);
if (ferror(file))
{
return errno;
}
But, ferror()
man page (man 3 ferror
, or just man ferror
) says:
ERRORS
These functions should not fail and do not set the external variableerrno
.
So, how can I know the error type occurred when file has been read, although fread()
and ferror()
didn't set errno
?