Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of the following mode declaration is used in C++ to open a file for input ?

  • A.ios : : app
  • B.in : : ios
  • C.ios : : file
  • D.ios : : in

Answer: D

The mode ios::in is used in C++ to open a file for input (reading). It is passed to the open function of the file stream, as in ifstream.open(name, ios::in).

ios::app opens a file for output in append mode. 'in::ios' reverses the class and the mode and is not valid, and ios::file is not a file mode. So only ios::in is right.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.