FAT | RFS | XFS | ZFS
fsetpos()
PROTOTYPE
#include <stdio.h>
int fsetpos(FILE *file, const fpos_t *pos);
DESCRIPTION
fsetpos() sets the current position of the open regular file indicated by file. The position is set to the value stored in *pos, which was obtained by a prior call to fgetpos().
If successful, fsetpos() clears the file’s end-of-file indicator, drops any byte stored on its file control block by ungetc(), and returns 0. Otherwise, it sets errno and returns a nonzero value.
ERROR CODES
| EBADF | file is not the handle of an open file. |
| EISDIR | The specified file is a directory. |
EXAMPLE
FILE *fp;
char buf[100];
fpos_t pos;
/*-------------------------------------------------------------------*/
/* Restore file's prior position and write 1 byte. */
/*-------------------------------------------------------------------*/
if (fsetpos(fp, &pos))
{
perror("fsetpos() failed");
return -1;
}
if (fwrite(buf, 1, 1, fp) != 1)
{
perror("fwrite() failed");
return -1;
}