Question 9
Back to Exercise
After reading a file to the end, why must you call in.clear() before in.seekg(0) to read it again?
- A To delete the file
- B The eof/fail flags are still set, and a stream with error flags ignores further operations Correct
- C To flush output
- D It is not necessary
Correct Answer: Option B
C++11 seekg clears eofbit, but failbit (set by the last failed read) must still be cleared.
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!