Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

fgetpos, fgetpos64 - get current value of file position indicator in stream

&pagelevel(4)&pagelevel

Syntax

#include <stdio.h>

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

Description

fgetpos() 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 information usable by  fsetpos() for repositioning the stream to its position at the time of the call to fgetpos().
There is no difference in functionality between fgetpos() and fgetpos64() except that  fgetpos64() uses a fpos64_t data type.

Return val.

0

!= 0

if successful.

if an error occurs; errno is set to indicate the error.

BS2000
errno is set to EBADF.

Errors

fgetpos() will fail if:

 

EBADF

The file descriptor underlying stream is not valid.

 

ESPIPE

The file descriptor underlying stream is associated with a pipe or FIFO.

Notes

The program environment determines whether fgetpos() is executed for a BS2000 or POSIX file.

BS2000
fgetpos() can be used on binary files (SAM in binary mode, PAM, INCORE) and text files (SAM in text mode, ISAM). fgetpos() cannot be used on system files (SYSDTA, SYSLST, SYSOUT).

For ISAM files, the function pair fgetpos()/fsetpos() is far more effective than the comparable function pair ftell()/fseek().
For record I/O, fgetpos() returns the position after the last record to be read, written or deleted or the position reached by an immediately preceding positioning operation.
For ISAM files with key duplication, fgetpos() always returns the position after the last record of a group with identical keys if one of these records has previously been read, written or deleted. 

See also

fseek(), fseek64(), lseek(), lseek64(), fsetpos(), fsetpos64(), ftell(), ftell64(), ungetc(), stdio.h.