1FTELL(3P)                  POSIX Programmer's Manual                 FTELL(3P)
2
3
4

PROLOG

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

NAME

12       ftell, ftello — return a file offset in a stream
13

SYNOPSIS

15       #include <stdio.h>
16
17       long ftell(FILE *stream);
18       off_t ftello(FILE *stream);
19

DESCRIPTION

21       The functionality described on this reference page is aligned with  the
22       ISO C  standard.  Any  conflict between the requirements described here
23       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2017
24       defers to the ISO C standard.
25
26       The  ftell()  function shall obtain the current value of the file-posi‐
27       tion indicator for the stream pointed to by stream.
28
29       The ftell() function shall not change the setting of errno if  success‐
30       ful.
31
32       The  ftello()  function shall be equivalent to ftell(), except that the
33       return value is of type off_t and the ftello() function may change  the
34       setting of errno if successful.
35

RETURN VALUE

37       Upon  successful completion, ftell() and ftello() shall return the cur‐
38       rent value of the file-position indicator for the  stream  measured  in
39       bytes from the beginning of the file.
40
41       Otherwise, ftell() and ftello() shall return -1, and set errno to indi‐
42       cate the error.
43

ERRORS

45       The ftell() and ftello() functions shall fail if:
46
47       EBADF  The file descriptor  underlying  stream  is  not  an  open  file
48              descriptor.
49
50       EOVERFLOW
51              For  ftell(), the current file offset cannot be represented cor‐
52              rectly in an object of type long.
53
54       EOVERFLOW
55              For ftello(), the current file offset cannot be represented cor‐
56              rectly in an object of type off_t.
57
58       ESPIPE The file descriptor underlying stream is associated with a pipe,
59              FIFO, or socket.
60
61       The following sections are informative.
62

EXAMPLES

64       None.
65

APPLICATION USAGE

67       None.
68

RATIONALE

70       None.
71

FUTURE DIRECTIONS

73       None.
74

SEE ALSO

76       Section 2.5, Standard I/O Streams, fgetpos(), fopen(), fseek(), lseek()
77
78       The Base Definitions volume of POSIX.1‐2017, <stdio.h>
79
81       Portions of this text are reprinted and reproduced in  electronic  form
82       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
83       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
84       cations  Issue  7, 2018 Edition, Copyright (C) 2018 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       Any typographical or formatting errors that appear  in  this  page  are
92       most likely to have been introduced during the conversion of the source
93       files to man page format. To report such errors,  see  https://www.ker
94       nel.org/doc/man-pages/reporting_bugs.html .
95
96
97
98IEEE/The Open Group                  2017                            FTELL(3P)
Impressum