Question 50

Which of the following commands in C++ will open a text file NOTES.TXT for reading the content from it ?

  1. Aifstream F ("NOTES.TXT");
  2. Bofstream F ("NOTES.TXT");
  3. Cfstream F ("NOTES.TXT");
  4. Dfstream F ("NOTES.TXT", ios :: read);
Show answerHide answer

Correct answer: (A) ifstream F ("NOTES.TXT");

Explanation

ifstream opens a file for input (reading). ofstream is for writing. ios::read is not a valid mode.

From DSSSB TGT Computer Science Practice Set 3

This is question 50 of DSSSB TGT Computer Science Practice Set 3. 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.