|FSEEK(3)||Linux Programmer's Manual||FSEEK(3)|
int fseek(FILE *stream, long offset, int whence);
long ftell(FILE *stream);
void rewind(FILE *stream);
int fgetpos(FILE *stream, fpos_t *pos);
int fsetpos(FILE *stream, const fpos_t *pos);
The ftell() function obtains the current value of the file position indicator for the stream pointed to by stream.
The rewind() function sets the file position indicator for the stream pointed to by stream to the beginning of the file. It is equivalent to:
except that the error indicator for the stream is also cleared (see clearerr(3)).
The fgetpos() and fsetpos() functions are alternate interfaces equivalent to ftell() and fseek() (with whence set to SEEK_SET), setting and storing the current value of the file offset into or from the object referenced by pos. On some non-UNIX systems, an fpos_t object may be a complex object and these routines may be the only way to portably reposition a text stream.
- The whence argument to fseek() was not SEEK_SET, SEEK_END, or SEEK_CUR. Or: the resulting file offset would be negative.
- The file descriptor underlying stream is not seekable (e.g., it refers to a pipe, FIFO, or socket).
|fseek (), ftell (), rewind (), fgetpos (), fsetpos ()||Thread safety||MT-Safe|