fsetpos

Sets the current file position according to the value of an object.

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

Syntax

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

Parameters

fp

(IN) Points to the file.

pos

(IN) Points to the object that specifies the new file position.

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.

9

EINVAL

The whence parameter is invalid.

12

ENOSPC

No free space remains on the device containing the file.

24

EAGAIN

The O_NONBLOCK flag is set for the file descriptor, and the process cannot immediately perform the operation.

25

ENXIO

A request was made of a nonexistent device, or the request was outside the capabilities of the device.

28

EIO

A physical I/O error has occurred.

32

EPIPE

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

63

EINTR

A signal interrupted the operation.

71

EFBIG

An attempt was made to write a file that exceeds the maximum file size.

Remarks

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

The fsetpos function clears the end-of-file indicator and undoes any effects of the ungetc function on the same file.

See Also