Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer


Sets the stream-position indicator.

int fsetpos( 
   FILE *stream,
   const fpos_t *pos 


Pointer to FILE structure.
Position-indicator storage.

Return Value

If successful, fsetpos returns 0. On failure, the function returns a nonzero value and sets errno to one of the following manifest constants (defined in ERRNO.H): EBADF, which means the file is not accessible or the object that stream points to is not a valid file structure; or EINVAL, which means an invalid stream value was passed.

See _doserrno, errno, _sys_errlist, and _sys_nerr for more information on these, and other, return codes.


The fsetpos function sets the file-position indicator for stream to the value of pos, which is obtained in a prior call to fgetpos against stream. The function clears the end-of-file indicator and undoes any effects of ungetc on stream. After calling fsetpos, the next operation on stream may be either input or output.


Function Required header Compatibility
fsetpos <stdio.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.


All versions of the C run-time libraries.


See the example for fgetpos.

See Also

Stream I/O Routines | fgetpos | Run-Time Routines and .NET Framework Equivalents

© 2015 Microsoft