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."
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.