Question 16

Which of the following file stream function will not move the file pointer to (N+1)th record of a binary file F created with the help of objects of class…

Which of the following file stream function will not move the file pointer to (N+1)th record of a binary file F created with the help of objects of class EMPLOYEE ?
  1. AF. seekp (N*sizeof (EMPLOYEE));
  2. BF. seekg (F.tellg( )*N);
  3. CF. seekg (sizeof (EMPLOYEE)*N);
  4. DPOS = sizeof (EMPLOYEE)*N;
Show answerHide answer

Correct answer: (B) F. seekg (F.tellg( )*N);

Explanation

seekg(F.tellg()*N) multiplies the current position by N, which is not the offset of the (N+1)th record. The correct offset is N*sizeof(EMPLOYEE).

From DSSSB TGT Computer Science Practice Set 2

This is question 16 of DSSSB TGT Computer Science Practice Set 2. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.