FAT | RFS | XFS | ZFS
ferror()
PROTOTYPE
#include <stdio.h>
int ferror(FILE *file);
DESCRIPTION
ferror() tests the error indicator of the open file identified by file. A file’s error indicator is set when an error occurs. It remains set until clearer() or rewind() are called, or the file is closed.
If file is invalid, ferror() sets errno to EINVAL and returns 0. Otherwise it doesn’t alter errno. ferror() returns nonzero if and only if the specified file’s error indicator is set.
ERROR CODES
| EINVAL | file is invalid. |
EXAMPLE
/*-----------------------------------------------------------------*/
/* Read to end of file. */
/*-----------------------------------------------------------------*/
do
{
rc = fread(Buf, 1, BUF_SIZE, file);
if (ferror(file))
{
perror("fread() failed");
return -1;
}
}
while (rc == BUF_SIZE);