< C++ Programming < Code < Standard C Library < Functions

fseek

Syntax
#include <cstdio>
int fseek( FILE *stream, long offset, int origin );

The function fseek() sets the file position data for the given stream. The origin value should have one of the following values (defined in cstdio):

NameExplanation
SEEK_SETSeek from the start of the file
SEEK_CURSeek from the current location
SEEK_ENDSeek from the end of the file

fseek() returns zero upon success, non-zero on failure. You can use fseek() to move beyond a file, but not before the beginning. Using fseek() clears the EOF flag associated with that stream.

Related topics
fgetpos - fopen - fsetpos - ftell - rewind
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.