Standard C++ Library Reference ISO/IEC (VERSION3)
arguments. It obtains each scanned character from the stream stream. It returns the number of
input items matched and assigned, or it returns EOF if the function does not store values before
it sets the end-of-file or error indicator for the stream.
fseek
int fseek(FILE *stream, long offset, int mode);
The function sets the file-position indicator for the stream stream (as specified by offset
and mode), clears the end-of-file indicator for the stream, and returns zero if successful.
For a binary stream, offset is a signed offset in bytes:
If mode has the value SEEK_SET, fseek adds offset to the file-position indicator
for the beginning of the file.
●
If mode has the value SEEK_CUR, fseek adds offset to the current file-position
indicator.
●
If mode has the value SEEK_END, fseek adds offset to the file-position indicator
for the end of the file (possibly after arbitrary null character padding).
●
fseek sets the file-position indicator to the result of this addition.
For a text stream:
If mode has the value SEEK_SET, fseek sets the file-position indicator to the value
encoded in offset, which is either a value returned by an earlier successful call to
ftell or zero to indicate the beginning of the file.
●
If mode has the value SEEK_CUR and offset is zero, fseek leaves the file-position
indicator at its current value.
●
If mode has the value SEEK_END and offset is zero, fseek sets the file-position
indicator to indicate the end of the file.
●
The function defines no other combination of argument values.
fsetpos
int fsetpos(FILE *stream, const fpos_t *pos);
The function sets the file-position indicator for the stream stream to the value stored in *pos,
clears the end-of-file indicator for the stream, and returns zero if successful. Otherwise, the
function stores a positive value in errno and returns a nonzero value.