Moves the file pointer to a specified location in a stream.
#include <stdio.h> int fseek (FILE *stream, long offset, int origin);
stream
offset
origin
SEEK_CUR | Current position of file pointer |
SEEK_END | End of file |
SEEK_SET | Beginning of file |
This function clears the end-of-file indicator and undoes effects of prior ungetc calls.
The next operation on the stream takes place at the new location. On a stream open for update, the next operation can be either a read or a write.
When a file is opened for appending data, the last I/O operation determines the current file pointer position, not where the next write would occur. If no I/O operation has yet occurred on a file opened for appending, the file position is the start of the file.
For streams opened in text mode, fseek has limited use because <CR><LF> translations can cause unexpected results. The only fseek operations guaranteed to work on streams opened in text mode are seeking with an offset of 0 relative to any origin value, or from the beginning of the file with an offset value returned by ftell.
Results are undefined on devices incapable of seeking, like terminals and printers.
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.0 | intime/rt/include/stdio.h | stdio.h | clib.lib |