1ferror(3)                  Library Functions Manual                  ferror(3)
2
3
4

NAME

6       clearerr, feof, ferror - check and reset stream status
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <stdio.h>
13
14       void clearerr(FILE *stream);
15       int feof(FILE *stream);
16       int ferror(FILE *stream);
17

DESCRIPTION

19       The function clearerr() clears the end-of-file and error indicators for
20       the stream pointed to by stream.
21
22       The function feof() tests the  end-of-file  indicator  for  the  stream
23       pointed  to by stream, returning nonzero if it is set.  The end-of-file
24       indicator can be cleared only by the function clearerr().
25
26       The function ferror() tests the error indicator for the stream  pointed
27       to  by stream, returning nonzero if it is set.  The error indicator can
28       be reset only by the clearerr() function.
29
30       For nonlocking counterparts, see unlocked_stdio(3).
31

RETURN VALUE

33       The feof() function returns nonzero if the end-of-file indicator is set
34       for stream; otherwise, it returns zero.
35
36       The ferror() function returns nonzero if the error indicator is set for
37       stream; otherwise, it returns zero.
38

ERRORS

40       These functions should not fail and do not set errno.
41

ATTRIBUTES

43       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
44       tributes(7).
45
46       ┌────────────────────────────────────────────┬───────────────┬─────────┐
47Interface                                   Attribute     Value   
48       ├────────────────────────────────────────────┼───────────────┼─────────┤
49clearerr(), feof(), ferror()                │ Thread safety │ MT-Safe │
50       └────────────────────────────────────────────┴───────────────┴─────────┘
51

STANDARDS

53       C11, POSIX.1-2008.
54

HISTORY

56       C89, POSIX.1-2001.
57

NOTES

59       POSIX.1-2008  specifies that these functions shall not change the value
60       of errno if stream is valid.
61

CAVEATS

63       Normally, programs should read the return value of an  input  function,
64       such  as  fgetc(3), before using functions of the feof(3) family.  Only
65       when the function returned the sentinel value EOF  it  makes  sense  to
66       distinguish  between the end of a file or an error with feof(3) or fer‐
67       ror(3).
68

SEE ALSO

70       open(2), fdopen(3), fileno(3), stdio(3), unlocked_stdio(3)
71
72
73
74Linux man-pages 6.04              2023-03-30                         ferror(3)
Impressum