fgetpos

Stores the current file position of a stream in an object.

Library:LibC
Classification:ANSI
Service:File and Directory I/O

Syntax

  #include <stdio.h> 
   
  int fgetpos (
     FILE     *fp, 
     fpos_t   *pos);
  

Parameters

fp

(IN) Points to the file.

pos

(OUT) Points to the object into which the position of the file is stored.

Return Values

If successful, returns 0. Otherwise, returns a nonzero value and sets errno to one of the following:

Decimal

Constant

Description

4

EBADF

The file descriptor is not valid.

81

EOVERFLOW

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

33

ESPIPE

The file descriptor is associated with a pipe, FIFO, or socket.

Remarks

The fgetpos function stores the current position of the file pointed to by fp in the object pointed to by pos. The value stored in pos is usable by the fsetpos function for repositioning the file to the position it had at the time of the call to fgetpos.

See Also