File: ferror.3

package info (click to toggle)
manpages 6.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,184 kB
  • sloc: sh: 575; python: 222; perl: 190; makefile: 29; lisp: 22
file content (108 lines) | stat: -rw-r--r-- 2,323 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
'\" t
.\" Copyright 1990-1991, The Regents of the University of California.
.\" Copyright, the authors of the Linux man-pages project
.\"
.\" SPDX-License-Identifier: BSD-4-Clause-UC
.\"
.TH ferror 3 2025-05-17 "Linux man-pages (unreleased)"
.SH NAME
clearerr, feof, ferror \- check and reset stream status
.SH LIBRARY
Standard C library
.RI ( libc ,\~ \-lc )
.SH SYNOPSIS
.nf
.B #include <stdio.h>
.P
.BI "void clearerr(FILE *" stream );
.BI "int feof(FILE *" stream );
.BI "int ferror(FILE *" stream );
.fi
.SH DESCRIPTION
The function
.BR clearerr ()
clears the end-of-file and error indicators for the stream pointed to by
.IR stream .
.P
The function
.BR feof ()
tests the end-of-file indicator for the stream pointed to by
.IR stream ,
returning nonzero if it is set.
The end-of-file indicator can be cleared only by the function
.BR clearerr ().
.P
The function
.BR ferror ()
tests the error indicator for the stream pointed to by
.IR stream ,
returning nonzero if it is set.
The error indicator can be reset only by the
.BR clearerr ()
function.
.P
For nonlocking counterparts, see
.BR unlocked_stdio (3).
.SH RETURN VALUE
The
.BR feof ()
function returns nonzero if the end-of-file indicator is set for
.IR stream ;
otherwise, it returns zero.
.P
The
.BR ferror ()
function returns nonzero if the error indicator is set for
.IR stream ;
otherwise, it returns zero.
.SH ERRORS
These functions should not fail and do not set
.IR errno .
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
.TS
allbox;
lbx lb lb
l l l.
Interface	Attribute	Value
T{
.na
.nh
.BR clearerr (),
.BR feof (),
.BR ferror ()
T}	Thread safety	MT-Safe
.TE
.SH STANDARDS
C11, POSIX.1-2008.
.SH HISTORY
C89, POSIX.1-2001.
.SH NOTES
POSIX.1-2008 specifies
.\"https://www.austingroupbugs.net/view.php?id=401
that these functions shall not change the value of
.I errno
if
.I stream
is valid.
.SH CAVEATS
Normally,
programs should read the return value of an input function,
such as
.BR fgetc (3),
before using functions of the
.BR feof (3)
family.
Only when the function returned the sentinel value
.B EOF
it makes sense to distinguish between the end of a file or an error with
.BR feof (3)
or
.BR ferror (3).
.SH SEE ALSO
.BR open (2),
.BR fdopen (3),
.BR fileno (3),
.BR stdio (3),
.BR unlocked_stdio (3)