fseek function(File Seek) in C Language – example and detail

In the C Programming Language, the fseek function changes the file role indicator for the circulation pointed to by means of stream.

Syntax

The syntax for the fseek function in the C Language is:

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

Parameters or Arguments

stream The flow whose file role indicator is to be modified. offset The offset to use (in bytes) when finding out the new file position. whence It can be one of the following values: Value Description SEEK_SET The new file role will be the establishing of the file plus offset (in bytes). SEEK_CUR The new file function will be the current position plus offset (in bytes). SEEK_END The new file role will be the give up of the file plus offset (in bytes).

Returns

The fseek feature returns zero if successful. If an error occurs, the fseek characteristic will return a nonzero value.

Required Header

In the C Language, the required header for the fseek feature is:

#include <stdio.h>

Applies To

In the C Language, the fseek feature can be used in the following versions:

ANSI/ISO 9899-1990

Similar Functions

Other C features that are similar to the fseek function:

fsetpos feature rewind feature

See Also

Other C features that are noteworthy when dealing with the fseek function:

fgetpos feature ftell function