NAME | SYNOPSIS | API RESTRICTIONS | DESCRIPTION | RETURN VALUES | ATTRIBUTES | SEE ALSO
$(OS_DIR)/lib/libc.a #include <stdio.h>int fseek(FILE * stream, long offset, int ptrname);
The function or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
The fseek() function sets the position of the next input or output operation on the stream . The new position, measured in bytes from the beginning of the file, is obtained by adding offset to the position specified by ptrname , whose values are defined in <stdio.h> as follows:
SEEK_SET Set position equal to offset bytes
SEEK_CUR Set position to current location plus offset
SEEK_END Set position to EOF plus offset
The rewind ( stream ) function is equivalent to fseek ( stream , 0L, 0), except that no value is returned.
The fseek() and rewind() functions undo any effects of ungetc (3STDC).
After performing fseek() or rewind() , the next operation on a file opened for update may be either input or output.
The ftell() function returns the offset of the current byte relative to the beginning of the file associated with the stream specified.
The fgetpos() and fsetpos() functions are alternate interfaces equivalent to ftell() and fseek() (with ptrname set to SEEK_SET ), setting and storing the current value of the file offset into or from the object referenced by pos . On some systems an fpos_t object may be a complex object, and these routines may be the only way to reposition a text stream portably. This is not the case on UNIX systems.
The fseek() function returns 0 on success; otherwise (for example, an fseek() done on a file that was not opened using fopen (3STDC)), it returns -1 and sets errno to indicate the error.
The ftell() function returns the offset on success, otherwise it returns -1.
The fsetpos() function returns 0 on success, otherwise it returns -1.
The fgetpos() function returns 0 on success, otherwise it returns 1.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
NAME | SYNOPSIS | API RESTRICTIONS | DESCRIPTION | RETURN VALUES | ATTRIBUTES | SEE ALSO