Which function can be used to check whether the end-of-file condition has been reached on a C++ stream?
Options
- A. eof()
- B. end()
- C. finish()
- D. More than one of the above
- E. None of the above
Quiz Practice:
A. eof()
Answer: (A) eof()
The eof() member function is used to test whether the end-of-file condition has been set for a stream.
For example:
if (file.eof()) {
// end-of-file condition
}
It returns a Boolean value indicating whether the stream's end-of-file state is set.
It is commonly encountered while studying C++ file and stream handling.