127k views
2 votes
What function do you use to move the current file pointer to a designated location in an open file?

a) fseek()
b) rewind()
c) fsetpos()
d) seekg()

User Finchsize
by
7.9k points

1 Answer

3 votes

Final answer:

The function used to move the current file pointer to a designated location is fseek(). It allows arbitrary repositioning of the file pointer within the file stream.

Step-by-step explanation:

To move the current file pointer to a designated location in an open file, the function you would use is fseek(). This function allows you to change the file pointer position in the file stream. For instance, fseek(filePtr, 10, SEEK_SET) moves the file pointer to the 10th byte in the file. The rewind() function sets the file pointer to the beginning of the file and does not allow for arbitrary positioning. The fsetpos() function is used in a similar manner to fseek() but uses a different kind of position indicator. Lastly, the seekg() function is specific to C++ streams and is not a standard C library function.

User Ishika
by
8.1k points