Repositions the file pointer of a stream.
#include <stdio.h>
int fseek ( Stream, Offset, Whence)
FILE *Stream;
long int Offset;
int Whence;
void rewind (Stream) FILE *Stream;
long int ftell (Stream) FILE *Stream;
int fgetpos (Stream, Position) FILE *Stream; fpos_t *Position;
int fsetpos (Stream, Position)
FILE *Stream;
const fpos_t *Position;
Note: The fseeko, fseeko64, ftello, ftello64, fgetpos64, and fsetpot64 subroutines apply to AIX 4.2 and later releases.
off_t int ftello (Stream) FILE *Stream;
off64_t int ftello64 (Stream) FILE *Stream;
int fgetpos64 (Stream, Position) FILE *Stream; fpos64_t *Position;
int fsetpos64 (Stream, Position)
FILE *Stream;
const fpos64_t *Position;
Note: The fseeko, fseeko64, ftello, ftello64, fgetpos64, and fsetpot64 subroutines apply to AIX 4.2 and later releases.
The fseek, fseeko and fseeko64 subroutines set the position of the next input or output operation on the I/O stream specified by the Stream parameter. The position if the next operation is determined by the Offset parameter, which can be either positive or negative.
The fseek, fseeko and fseeko64 subroutines set the file pointer associated with the specified Stream as follows:
The fseek, fseeko, and fseeko64 subroutine are unsuccessful if attempted on a file that has not been opened using the fopen (fopen, fopen64, freopen, freopen64 or fdopen Subroutine) subroutine. In particular, the fseek subroutine cannot be used on a terminal or on a file opened with the popen (popen Subroutine) subroutine. The fseek and fseeko subroutines will also fail when the resulting offset is larger than can be properly returned.
The rewind subroutine is equivalent to calling the fseek subroutine using parameter values of (Stream,SEEK_SET,SEEK_SET), except that the rewind subroutine does not return a value.
The fseek, fseeko, fseeko64 and rewind subroutines undo any effects of the ungetc and ungetwc subroutines and clear the end-of-file (EOF) indicator on the same stream.
The fseek, fseeko, and fseeko64 function allows the file-position indicator to be set beyond the end of existing data in the file. If data is written later at this point, subsequent reads of data in the gap will return bytes of the value 0 until data is actually written into the gap.
A successful calls to the fsetpos or fsetpos64 subroutines clear the EOF indicator and undoes any effects of the ungetc and ungetwc subroutines.
After an fseek, fseeko, fseeko64 or a rewind subroutine, the next operation on a file opened for update can be either input or output.
ftell, ftello and ftello64 subroutines return the position current value of the file-position indicator for the stream pointed to by the Stream parameter. ftell and ftello will fail if the resulting offset is larger than can be properly returned.
The fgetpos and fgetpos64 subroutines store the current value of the file-position indicator for the stream pointed to by the Stream parameter in the object pointed to by the Position parameter. The fsetpos and fsetpos64 set the file-position indicator for Stream according to the value of the Position parameter, which must be the result of a prior call to fgetpos or fgetpos64 subroutine. fgetpos and fsetpos will fail if the resulting offset is larger than can be properly returned.
Upon successful completion, the fseek, fseeko and fseeko64 subroutine return a value of 0. Otherwise, it returns a value of -1.
Upon successful completion, the ftell, ftello and ftello64 subroutine return the offset of the current byte relative to the beginning of the file associated with the named stream. Otherwise, a long int value of -1 is returned and the errno global variable is set.
Upon successful completion, the fgetpos, fgetpos64, fsetpos and fsetpos64 subroutines return a value of 0. Otherwise, a nonzero value is returned and the errno global variable is set to the specific error.
The errno global variable is used to determine if an error occurred during a rewind subroutine call.
If the fseek,
fseeko, fseeko64, ftell, ftello,
ftello64 or rewind subroutine are unsuccessful because the
stream is unbuffered or the stream buffer needs to be flushed and the call to
the subroutine causes an underlying lseek or write
subroutine to be invoked, it returns one or more of the following error
codes:
The fgetpos and
fsetpos subroutines are unsuccessful due to the following
conditions:
The fseek,
fseeko, ftell, ftello, fgetpos,
and fsetpos subroutines are unsuccessful under the following
condition:
EOVERFLOW | The resulting could not be returned properly. |
These subroutines are part of Base Operating system (BOS) Runtime.
The closedir (opendir, readdir, telldir, seekdir, rewinddir, or closedir Subroutine) subroutine, fopen, fopen64, freopen, freopen64 or fdopen (fopen, fopen64, freopen, freopen64 or fdopen Subroutine) subroutine, lseek or lseek64 (lseek, llseek or lseek64 Subroutine)subroutine, opendir, readdir, rewinddir, seekdir, or telldir (opendir, readdir, telldir, seekdir, rewinddir, or closedir Subroutine)subroutine, popen (popen Subroutine) subroutine, ungetc or ungetwc subroutine, write, writex, writev, or writevx subroutine.
Input and Output Handling in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.