LearnFrenzy
Sign in Take a free test

File Handling (fstream) · File Handling MCQ · Question 20

Making file streams throw exceptions Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 20 Back to Exercise

What does in.exceptions(std::ios::failbit | std::ios::badbit); do?

  • A Disables errors
  • B Makes the stream throw std::ios_base::failure whenever failbit or badbit becomes set Correct
  • C Prints errors
  • D Opens the file in binary
Correct Answer: Option B

Be careful: reaching the end of file with a read also sets failbit, so the final failing read of a loop would throw too.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links