Shiny Language Reference

Language Reference > File Functions


fseek

bool fseek(file FileVar, offset_specifier, int Offset);

 

 

Seeks to a position within an open file

The FSEEK statement changes the "next byte to read" pointer in a file to the specified position. It is normally used to seek to the start or end of a file.

 

Parameters

FileVar

A variable declared as type FILE which has previously been associated with a file by using FOPEN.

OffsetSpecifier

One of the following constants, specifying the starting position of the seek operation

POS_START - Begin seeking from the start of the file

POS_CURR - Begin seeking from the current position in the file

POS_END - Begin seeking from the end of the file

Offset

The number of bytes to move by

 

Return Value

TRUE if seeking in the file suceeded, otherwise FALSE.

 

Example Code

file myfile;

if(fopen(myfile, "C:\\Readme.txt") == FALSE)
{
    // Seek in 10 bytes from the start of the file
    fseek(myfile, pos_start, 10);

    // Seek a further 10 bytes, final position will be 20 bytes in
    fseek(myfile, pos_curr, 10);
}