fseek(), fseeko(), fseeko64()

reposition a stream's file pointer 

Function


SYNOPSIS

#include <stdio.h>

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

int fseeko(FILE *stream, off_t offset, int whence);

int fseeko64(FILE *stream, off64_t offset, int whence);


DESCRIPTION

The fseek() function repositions a file pointer for a stream.

The fseeko() function is identical to fseek() except for the type of the offset.

The fseeko64() function is a part of the large file extensions, and is similar to fseeko() except that a larger file offset can be specified.

If the stream is writable, and buffered data has not yet been written to the underlying file, fseek() causes the unwritten data to be written to the file, and marks the st_ctime and st_mtime fields of the file for update.


PARAMETERS

stream 

Points to the stream whose file pointer is to repositioned

offset 

Is the new position in the file (relative to whence) for the file pointer.

whence 

Specifies from what point the offset is determined.


RETURN VALUES

The fseek(), fseeko(), and fseeko64() functions return 0 if they succeed; otherwise, they return -1 and errno is set to one of the following values:

EAGAIN 

The O_NONBLOCK flag is set for the file descriptor underlying stream, and the process would be delayed in the write operation.

EBADF 

The file descriptor underlying stream is not valid.

EFBIG 

The file is a regular file and an attempt was made to write at or beyond the offset maximum associated with the corresponding stream.

EINTR 

A signal interrupted the call.

EINVAL 

The whence argument is invalid.

ENOSPC 

There was no free space remaining on the device containing the file.

EOVERFLOW 

The resulting file offset would be a value which cannot be represented correctly in an object of the requested type.

EPIPE 

An attempt is made to write to a pipe or FIFO that is not open for reading by any process. A SIGPIPE signal is also sent to the process.


CONFORMANCE

ANSI/ISO 9899-1990.

fseeko(), fseeko64(): Large File Specification, revision 1.5.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

The file positions reported by fgetpos(), ftell(), ftello() may be incorrect for files that are open in text mode in the case that the file is being read, or the case where the file is being written to and there is buffered data which has not yet been written to the underlying file. In the case that the file is being written to, fflush() can be used prior to calling fgetpos() ftell(), or ftello() to ensure the accuracy of these functions. Text mode files with no buffering do not have this problem, however performance can be significantly degraded with buffering turned off.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
fopen(), ftell(), lseek(), popen(), rewind(), ungetc(), write()

Miscellaneous:
lf64


PTC MKS Toolkit 10.4 Documentation Build 39.