fgetpos -- Store the Current File Position

SYNOPSIS

 #include <stdio.h>

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

DESCRIPTION

fgetpos determines the current file position for the stream associated with the FILE object addressed by f, and it stores the file position in the object pointed to by pos. This object is of type fpos_t, which is defined in stdio.h. The stored value can be passed to the fsetpos function to reposition the file to its position at the time of the call to fgetpos.

You can use fgetpos with most types of files, using either text or binary access. Note that you can use it to obtain the current position for many files that ftell cannot process, including files accessed as a binary stream using the "seq" access method. See Tables 3.5 and 3.6 for file types that are not fully supported by fgetpos.

RETURN VALUES

If successful, fgetpos returns 0. If it fails, fgetpos returns a nonzero value and stores an appropriate error code in errno. See The errno Variable for the list of errno values.

A program that uses the components of an fpos_t value is not portable.

IMPLEMENTATION

See File positioning with fgetpos and fsetpos for information on the implementation of fgetpos and the structure of fpos_t values.

EXAMPLE

See the example for fsetpos.

RELATED FUNCTIONS

fsetpos, ftell, kgetpos, lseek

SEE ALSO


Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.