The Open Group Base Specifications Issue 6
IEEE Std 1003.1, 2004 Edition
Copyright © 2001-2004 The IEEE and The Open Group, All Rights reserved.

#### NAME

> ftell, ftello - return a file offset in a stream

#### SYNOPSIS

> ``#include <stdio.h>
> long ftell(FILE *`stream`);
> ``

> ``[CX] off_t ftello(FILE *`stream`);``
> `
> `

#### DESCRIPTION

> [CX] The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of IEEE Std 1003.1-2001 defers to the ISO C standard.

> The ftell() function shall obtain the current value of the file-position indicator for the stream pointed to by stream.

> [CX] The ftello() function shall be equivalent to ftell(), except that the return value is of type off_t.

#### RETURN VALUE

> Upon successful completion, ftell() [CX] and ftello() shall return the current value of the file-position indicator for the stream measured in bytes from the beginning of the file.

> Otherwise, ftell() [CX] and ftello() shall return -1, cast to long and off_t respectively, and set errno to indicate the error.

#### ERRORS

> The ftell() [CX] and ftello() functions shall fail if:

> [EBADF]
>   [CX] The file descriptor underlying stream is not an open file descriptor.
> [EOVERFLOW]
>   [CX] For ftell(), the current file offset cannot be represented correctly in an object of type long.
> [EOVERFLOW]
>   [CX] For ftello(), the current file offset cannot be represented correctly in an object of type off_t.
> [ESPIPE]
>   [CX] The file descriptor underlying stream is associated with a pipe or FIFO.

> The ftell() function may fail if:

> [ESPIPE]
>   [CX] The file descriptor underlying stream is associated with a socket.

The following sections are informative.

#### EXAMPLES

> None.

#### APPLICATION USAGE

> None.

#### RATIONALE

> None.

#### FUTURE DIRECTIONS

> None.

#### SEE ALSO

> fgetpos(), fopen(), fseek() , lseek(), the Base Definitions volume of IEEE Std 1003.1-2001, <stdio.h>

#### CHANGE HISTORY

> First released in Issue 1. Derived from Issue 1 of the SVID.

#### Issue 5

> Large File Summit extensions are added.

#### Issue 6

> Extensions beyond the ISO C standard are marked.

> The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:

> - The ftello() function is added.

> - The [EOVERFLOW] error conditions are added.

> An additional [ESPIPE] error condition is added for sockets.

End of informative text.

UNIX ® is a registered Trademark of The Open Group.
POSIX ® is a registered Trademark of The IEEE.
[ Main Index | XBD | XCU | XSH | XRAT ]