Go to main content

man pages section 3: Basic Library Functions

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

fgetpos(3C)

Name

fgetpos - get current file position information

Synopsis

#include <stdio.h>

int fgetpos(FILE *stream, fpos_t *pos);

Description

The fgetpos() function stores the current value of the file position indicator for the stream pointed to by stream in the object pointed to by pos. The value stored contains unspecified information usable by fsetpos(3C) for repositioning the stream to its position at the time of the call to fgetpos().

Return Values

Upon successful completion, fgetpos() returns 0. Otherwise, it returns a non-zero value and sets errno to indicate the error.

Errors

The fgetpos() function may fail if:

EBADF

The file descriptor underlying stream is not valid.

ESPIPE

The file descriptor underlying stream is associated with a pipe, a FIFO, a socket, or a STREAMS device.

EOVERFLOW

The current value of the file position cannot be represented correctly in an object of type fpos_t.

Usage

The fgetpos() function has a transitional interface for 64-bit file offsets. See lf64(7).

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Standard

See Also

ftell(3C), fopen(3C), fsetpos(3C), rewind(3C), ungetc(3C), attributes(7), lf64(7), standards(7)