1 .\" Copyright (c) 1990, 1991 The Regents of the University of California.
2 .\" All rights reserved.
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Chris Torek and the American National Standards Committee X3,
6 .\" on Information Processing Systems.
8 .\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
17 .\" 3. All advertising materials mentioning features or use of this software
18 .\" must display the following acknowledgement:
19 .\" This product includes software developed by the University of
20 .\" California, Berkeley and its contributors.
21 .\" 4. Neither the name of the University nor the names of its contributors
22 .\" may be used to endorse or promote products derived from this software
23 .\" without specific prior written permission.
25 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 .\" @(#)fseek.3 6.11 (Berkeley) 6/29/91
40 .\" Converted for Linux, Mon Nov 29 15:22:01 1993, faith@cs.unc.edu
42 .TH FSEEK 3 2018-04-30 "GNU" "Linux Programmer's Manual"
44 fgetpos, fseek, fsetpos, ftell, rewind \- reposition a stream
48 .BI "int fseek(FILE *" stream ", long " offset ", int " whence );
50 .BI "long ftell(FILE *" stream );
52 .BI "void rewind(FILE *" stream );
54 .BI "int fgetpos(FILE *" stream ", fpos_t *" pos );
56 .BI "int fsetpos(FILE *" stream ", const fpos_t *" pos );
60 function sets the file position indicator for the stream pointed to by
62 The new position, measured in bytes, is obtained by adding
64 bytes to the position specified by
73 the offset is relative to the start of the file, the current position
74 indicator, or end-of-file, respectively.
75 A successful call to the
77 function clears the end-of-file indicator for the stream and undoes
80 function on the same stream.
84 function obtains the current value of the file position indicator for the
90 function sets the file position indicator for the stream pointed to by
92 to the beginning of the file.
96 (void) fseek(stream, 0L, SEEK_SET)
99 except that the error indicator for the stream is also cleared (see
106 functions are alternate interfaces equivalent to
114 setting and storing the current value of the file offset into or from the
117 On some non-UNIX systems, an
119 object may be a complex object and these routines may be the only way to
120 portably reposition a text stream.
124 function returns no value.
125 Upon successful completion,
132 returns the current offset.
133 Otherwise, \-1 is returned and
135 is set to indicate the error.
148 Or: the resulting file offset would be negative.
151 The file descriptor underlying
153 is not seekable (e.g., it refers to a pipe, FIFO, or socket).
161 may also fail and set
163 for any of the errors specified for the routines
170 For an explanation of the terms used in this section, see
176 Interface Attribute Value
184 T} Thread safety MT-Safe
188 POSIX.1-2001, POSIX.1-2008, C89, C99.