2 .\" Copyright (c) 1990, 1991 The Regents of the University of California.
3 .\" All rights reserved.
5 .\" This code is derived from software contributed to Berkeley by
6 .\" Chris Torek and the American National Standards Committee X3,
7 .\" on Information Processing Systems.
9 .\" SPDX-License-Identifier: BSD-4-Clause-UC
11 .\" @(#)fseek.3 6.11 (Berkeley) 6/29/91
13 .\" Converted for Linux, Mon Nov 29 15:22:01 1993, faith@cs.unc.edu
15 .TH fseek 3 (date) "Linux man-pages (unreleased)"
17 fgetpos, fseek, fsetpos, ftell, rewind \- reposition a stream
20 .RI ( libc ", " \-lc )
25 .BI "int fseek(FILE *" stream ", long " offset ", int " whence );
26 .BI "long ftell(FILE *" stream );
28 .BI "void rewind(FILE *" stream );
30 .BI "int fgetpos(FILE *restrict " stream ", fpos_t *restrict " pos );
31 .BI "int fsetpos(FILE *" stream ", const fpos_t *" pos );
36 function sets the file position indicator for the stream pointed to by
38 The new position, measured in bytes, is obtained by adding
40 bytes to the position specified by
49 the offset is relative to the start of the file, the current position
50 indicator, or end-of-file, respectively.
51 A successful call to the
53 function clears the end-of-file indicator for the stream and undoes
56 function on the same stream.
60 function obtains the current value of the file position indicator for the
66 function sets the file position indicator for the stream pointed to by
68 to the beginning of the file.
72 (void) fseek(stream, 0L, SEEK_SET)
75 except that the error indicator for the stream is also cleared (see
82 functions are alternate interfaces equivalent to
90 setting and storing the current value of the file offset into or from the
93 On some non-UNIX systems, an
95 object may be a complex object and these routines may be the only way to
96 portably reposition a text stream.
98 If the stream refers to a regular file
99 and the resulting stream offset is beyond the size of the file,
100 subsequent writes will extend the file with a hole, up to the offset,
101 before committing any data.
104 for details on file seeking semantics.
108 function returns no value.
109 Upon successful completion,
116 returns the current offset.
117 Otherwise, \-1 is returned and
119 is set to indicate the error.
132 Or: the resulting file offset would be negative.
135 The file descriptor underlying
137 is not seekable (e.g., it refers to a pipe, FIFO, or socket).
145 may also fail and set
147 for any of the errors specified for the routines
154 For an explanation of the terms used in this section, see
160 Interface Attribute Value
169 T} Thread safety MT-Safe