BSD 4_2 development
[unix-history] / usr / man / man3 / fseek.3s
CommitLineData
a6c517c9
C
1.TH FSEEK 3S "19 January 1983"
2.SH NAME
3fseek, ftell, rewind \- reposition a stream
4.SH SYNOPSIS
5.B #include <stdio.h>
6.PP
7.B fseek(stream, offset, ptrname)
8.br
9.SM
10.B FILE
11.B *stream;
12.br
13.B long offset;
14.PP
15.B long ftell(stream)
16.br
17.SM
18.B FILE
19.B *stream;
20.PP
21.B rewind(stream)
22.SH DESCRIPTION
23.I Fseek
24sets the position of the next input or output
25operation on the
26.IR stream .
27The new position is at the signed distance
28.I offset
29bytes
30from the beginning, the current position, or the end of the file,
31according as
32.I ptrname
33has the value 0, 1, or 2.
34.PP
35.I Fseek
36undoes any effects of
37.IR ungetc (3S).
38.PP
39.I Ftell
40returns the current value of the offset relative to the beginning
41of the file associated with the named
42.IR stream .
43It is measured in bytes on UNIX;
44on some other systems it is a magic cookie,
45and the only foolproof way to obtain an
46.I offset
47for
48.IR fseek .
49.PP
50.IR Rewind ( stream )
51is equivalent to
52.IR fseek ( stream ,
530L, 0).
54.SH "SEE ALSO"
55lseek(2),
56fopen(3S)
57.SH DIAGNOSTICS
58.I Fseek
59returns \-1 for improper seeks.