INtime SDK Help
fseek

Moves the file pointer to a specified location in a stream.

#include <stdio.h>

int fseek (FILE *stream, long offset, int origin);

Parameters

stream
Pointer to FILE structure.
offset
Number of bytes from origin.
origin
Initial position, specified as one of these, or beyond end-of-file. An attempt to position the pointer before the beginning of the file causes an error.
SEEK_CUR Current position of file pointer
SEEK_END End of file
SEEK_SET Beginning of file

Remarks

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.

Return Values

0 (zero).
Success.
Any other value.
Failure.

Requirements

Versions Defined in Include Link to
INtime 3.0 intime/rt/include/stdio.h stdio.h clib.lib

See Also

ftell, lseek, rewind