1FTELL(3P) POSIX Programmer's Manual FTELL(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 ftell, ftello - return a file offset in a stream
13
15 #include <stdio.h>
16
17 long ftell(FILE *stream);
18
19
20 off_t ftello(FILE *stream);
21
22
24 The ftell() function shall obtain the current value of the file-posi‐
25 tion indicator for the stream pointed to by stream.
26
27 The ftello() function shall be equivalent to ftell(), except that the
28 return value is of type off_t.
29
31 Upon successful completion, ftell() and ftello() shall return the
32 current value of the file-position indicator for the stream measured in
33 bytes from the beginning of the file.
34
35 Otherwise, ftell() and ftello() shall return -1, cast to long and
36 off_t respectively, and set errno to indicate the error.
37
39 The ftell() and ftello() functions shall fail if:
40
41 EBADF The file descriptor underlying stream is not an open file
42 descriptor.
43
44 EOVERFLOW
45 For ftell(), the current file offset cannot be represented cor‐
46 rectly in an object of type long.
47
48 EOVERFLOW
49 For ftello(), the current file offset cannot be represented cor‐
50 rectly in an object of type off_t.
51
52 ESPIPE The file descriptor underlying stream is associated with a pipe
53 or FIFO.
54
55
56 The ftell() function may fail if:
57
58 ESPIPE The file descriptor underlying stream is associated with a
59 socket.
60
61
62 The following sections are informative.
63
65 None.
66
68 None.
69
71 None.
72
74 None.
75
77 fgetpos(), fopen(), fseek(), lseek(), the Base Definitions volume of
78 IEEE Std 1003.1-2001, <stdio.h>
79
81 Portions of this text are reprinted and reproduced in electronic form
82 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
83 -- Portable Operating System Interface (POSIX), The Open Group Base
84 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
85 Electrical and Electronics Engineers, Inc and The Open Group. In the
86 event of any discrepancy between this version and the original IEEE and
87 The Open Group Standard, the original IEEE and The Open Group Standard
88 is the referee document. The original Standard can be obtained online
89 at http://www.opengroup.org/unix/online.html .
90
91
92
93IEEE/The Open Group 2003 FTELL(3P)