Write the syntax and explain the purpose of the following functions : Fseek() 2m Dec2005

By | June 10, 2014

Write the syntax and explain the purpose of the following functions : 2m Dec2005

(i) Fseek( )

Description

The C library function int fseek(FILE *stream, long int offset, int whence) sets the file position of the stream to the given offset.

Declaration

Following is the declaration for fseek() function.

int fseek(FILE *stream, long int offset, int whence)
Parameters
  • stream — This is the pointer to a FILE object that identifies the stream.
  • offset — This is the number of bytes to offset from whence.
  • whence — This is the position from where offset is added. It is specified by one of the following constants:

Constant

Description

SEEK_SET

Beginning of file

SEEK_CUR

Current position of the file pointer

SEEK_END

End of file

Return Value

This function returns zero if successful, else it returns nonzero value.

Leave a Reply