Multiple choice

Which of the following functions is used to place the pointer at a particular position in a file?

  1. seekp()

  2. rewind()

  3. ftell()

  4. fseek()

  5. fread()

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The fseek() is used to move the pointer at any position in a file. It is used in programs where we want to read or write data from/to a specific position in a file. It has the following syntax - fseek(filepointer,int bytes,int offset) where file pointer is a pointer pointing to a file. bytes - is the number of bytes that we want to move. offset - denotes the position from where we want to move.for example  fseek(fp,10,0) will move the pointer 10 bytes from the beginning.