Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 1. the fseek() function can move the file point when reading data from

ID: 3786679 • Letter: Q

Question

Question 1. the fseek() function can move the file point when reading data from a file. Assum that the original example.txt reads the following:

This is an apple.

After the execution of the following line , what would the file example.txt contain?

  FILE * pFile;

pFile = fopen ( "example.txt" , "wb" );

fseek ( pFile , 10 , SEEK_SET );

fputs ( " sam" , pFile );

       (a) This is an apple.

       (b) This is a sample.

       (c) This is an samle.

       (d) This is an sample.

       (e) None of (a) through (d) is the correct answer.

Explanation / Answer

Answer: (c) This is an samle.

fseek ( pFile , 10 , SEEK_SET );

this statement will seek for 10 position in the line in file. 10th position will start from space. Highlighted below.

This is an apple.

So when we put " sam" in file, it will replace the " app" in file.

so now file content is "This is an samle."

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote