Commit | Line | Data |
---|---|---|
bb0a128d | 1 | .\" @(#)fseek.3 6.4 (Berkeley) %G% |
4f278f49 | 2 | .\" |
0431d494 | 3 | .TH FSEEK 3S "" |
4f278f49 KM |
4 | .AT 3 |
5 | .SH NAME | |
6 | fseek, ftell, rewind \- reposition a stream | |
7 | .SH SYNOPSIS | |
8 | .B #include <stdio.h> | |
9 | .PP | |
edb5b917 | 10 | .B fseek(stream, offset, ptrname) |
4f278f49 KM |
11 | .br |
12 | .SM | |
13 | .B FILE | |
14 | .B *stream; | |
15 | .br | |
16 | .B long offset; | |
17 | .PP | |
18 | .B long ftell(stream) | |
19 | .br | |
20 | .SM | |
21 | .B FILE | |
22 | .B *stream; | |
23 | .PP | |
24 | .B rewind(stream) | |
25 | .SH DESCRIPTION | |
26 | .I Fseek | |
27 | sets the position of the next input or output | |
28 | operation on the | |
29 | .IR stream . | |
30 | The new position is at the signed distance | |
31 | .I offset | |
32 | bytes | |
33 | from the beginning, the current position, or the end of the file, | |
34 | according as | |
35 | .I ptrname | |
36 | has the value 0, 1, or 2. | |
37 | .PP | |
38 | .I Fseek | |
39 | undoes any effects of | |
11d86b43 | 40 | .IR ungetc (3S). |
4f278f49 KM |
41 | .PP |
42 | .I Ftell | |
43 | returns the current value of the offset relative to the beginning | |
44 | of the file associated with the named | |
45 | .IR stream . | |
46 | It is measured in bytes on UNIX; | |
47 | on some other systems it is a magic cookie, | |
48 | and the only foolproof way to obtain an | |
49 | .I offset | |
50 | for | |
51 | .IR fseek . | |
52 | .PP | |
11d86b43 | 53 | .IR Rewind ( stream ) |
4f278f49 | 54 | is equivalent to |
11d86b43 | 55 | .IR fseek ( stream , |
bb0a128d | 56 | 0L, L_SET). |
4f278f49 KM |
57 | .SH "SEE ALSO" |
58 | lseek(2), | |
11d86b43 | 59 | fopen(3S) |
edb5b917 JL |
60 | .SH DIAGNOSTICS |
61 | .I Fseek | |
62 | returns \-1 for improper seeks, otherwise zero. |