fseek(), fseeko(), rewind(), ftell(), ftello() - reposition a file pointer in a stream
sets the file-position indicator for stream. The new position, measured in bytes from the beginning of the file, is obtained by adding
offset to the position specified by whence. The specified position is the beginning of the file for the current position for or end-of-
is a non-POSIX standard API provided by the compile option. It is identical to the except that the offset parameter is an instead of a All
other functional behaviors, returns, and errors are identical to the POSIX
If the most recent operation, other than on the stream is the file offset in the underlying open file description is adjusted to reflect
the location specified by the
is equivalent to except that no value is returned.
and undo any effects of ungetc(3S).
After or the next operation on a file opened for update can be either input or output. clears the EOF indicator for the stream. does an
implicit call (see ferror(3S)).
returns the offset of the current byte relative to the beginning of the file associated with the named stream.
is a non-POSIX standard API provided by the compile option. It is identical to the except that it returns an instead of a All other behav-
iors, returns, and errors are identical to the POSIX
and reposition a file pointer in a stream.
and return zero if they succeed. Otherwise they return -1 and set to indicate the error.
and return the current value of the file position indicator for the stream measured in bytes from the beginning of the file. Otherwise,
and return -1 and set to indicate the error.
and do not return any value. Therefore, any application that needs to detect errors should clear before calling or Then, upon completion,
if is non-zero, it should assume an error has occurred.
and fail if the stream is unbuffered or the buffered data needs to be flushed, or if any of the following conditions are encountered:
The flag is set for the file descriptor and the process would be delayed in the write operation.
The stream is NULL.
The underlying file is not open for writing.
An attempt was made to write a file
that exceeds the process's file size limit or the maximum file size. See ulimit(2).
The file offset cannot be represented correctly in an object of type or size in this environment.
A signal was caught during the write operation.
The process is in a background process group
and is attempting to write to its controlling terminal, is set, the process is neither ignoring nor blocking the
signal, and the process group of the process is orphaned.
There was no free space remaining on the device containing the file.
An attempt was made to write to a pipe
that is not open for reading by any process. A signal is also sent to the process.
A seek operation was attempted and the file descriptor underlying
stream is associated with a pipe.
also fail if:
The whence argument is invalid, or the file-position indicator would be set to a negative value.
Additional values may be set by the underlying and functions (see write(2) and lseek(2)).
On HP-UX systems, the offset returned by is measured in bytes and it is permissible to seek to positions relative to that offset. However,
when porting to non-HP-UX systems, should be used directly without relying on any offset obtained from because arithmetic cannot meaning-
fully be performed on such an offset if it is not measured in bytes on a particular operating system.
and have no effect on streams that have been opened in append mode (see fopen(3S)).
and are obsolescent interfaces supported for compatibility with existing DCE applications. New multithreaded applications should use and
lseek(2), write(2), ferror(3S), flockfile(3S), fopen(3S), fgetpos(3S), fgetpos64(3S), ungetc(3S), thread_safety(5).