Question 15

Which of the following C++ Statements will open a text file "VIEWS. TXT" in which read as well as write activities are required at the same time?

  1. AFstream F ("VIEWS.TXT", ios :: read | ios :: write);
  2. BFstream F ("VIEWS.TXT", ios :: in | ios :: out);
  3. CFstream F ("VIEWS.TXT", ios :: in | out);
  4. DFstream F ("VIEWS.TXT", ios :: read | write);
Show answerHide answer

Correct answer: (B) Fstream F ("VIEWS.TXT", ios :: in | ios :: out);

Explanation

An fstream opened with ios::in | ios::out allows both reading and writing. ios::read and ios::write do not exist.

From DSSSB TGT Computer Science Practice Set 2

This is question 15 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.