Multiple choice

Which of the following functions can be used to randomly access a file?

  1. fgetc

  2. getc

  3. fseek

  4. all of the above

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

It is used to set the file-position indicator for the stream pointed to by the stream. The new position is measured in bytes from the begning of the file and obtained by adding offset to the position specified by whence, whose values are defined in <stdio.h>. fseek() function is used to randomly access a file. For example: int fseek(FILE *stream, long offset, int whence);