[Previous]
[Contents]
[Next]

fsetpos()

set the current file position

Synopsis:

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

Description:

The fsetpos() function positions the file fp according to the value of the object pointed to by pos, which must be a value returned by an earlier call to the fgetpos() function on the same file.

Returns:

0
Success
Nonzero
An error occurred. errno is set to indicate the error.

Examples:

#include <stdio.h>

void main()
  {
    FILE *fp;
    fpos_t position;
    char buffer[80];

    fp = fopen( "file", "r" );
    if( fp != NULL ) {
      fgetpos( fp, &position );   /* get position     */
      fgets( buffer, 80, fp );    /* read record        */
      fsetpos( fp, & position );  /* set position     */
      fgets( buffer, 80, fp );    /* read same record */
      fclose( fp );
    }
  }

Classification:

ANSI

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

errno, fgetpos(), fopen(), fseek(), ftell()


[Previous]
[Contents]
[Next]