fseek
- Updated2023-02-21
- 2 minute(s) read
fseek
int fseek (FILE *stream, long offset, int origin);
Purpose
Sets the file position indicator for the specified stream. The value specified by offset is added to the position designated by origin. A successful call to this function clears the end-of-file indicator for the stream and undoes any effects of ungetc on the same stream. After a call to this function, the next operation on an update stream (read/write or read/append) may be either input or output.
![]() |
Note This function is similar to fsetpos; however, fsetpos is more useful for huge files (over 2 billion bytes). |
Parameters
Input | ||||||||||||||
Name | Type | Description | ||||||||||||
stream | FILE * | Contains a pointer to the stream that has its associated file position indicator set. | ||||||||||||
offset | long | Contains the number of bytes beyond the designated origin to set the file position indicator. For binary files, this value is measured in characters and is added to the specified origin. For text files, one of the following must be true:
|
||||||||||||
origin | int |
Contains the origin to which the specified offset is
added in computing the new file position. The following describes the
available selections:
|
Return Value
Name | Type | Description |
status | int | Contains the returned status of the function. If successful, fseek returns 0. If an error occurs, fseek returns a nonzero value and sets errno to a nonzero value. |
Additional Information
Library: ANSI C Library
Include file: ansi_c.h
LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later