How to detect an end of a file? - C++

How to detect an end of a file?

End of file in C++ can be detected using eof. End Of File returns non - zero value if the end of file (EOF) is encountered and a zero otherwise. The condition can be checked as follows :
If(last1.eof()!=0){};

How to detect an end of a file?

You can either use the ifstream object ‘fin’ which returns 0 on an end of file or you can use eof() which is a member function of the ios class. It returns a non zero value on reaching the end of file.
What are recursive functions?
What are recursive functions? - A recursive function is a function which calls itself...
Difference between an external iterator and an internal iterator
Difference between an external iterator and an internal iterator - An internal iterator is implemented by the member functions of the class....
Explain passing objects by reference, passing objects by value and passing objects by pointer
Passing objects by reference, passing objects by value and passing objects by pointer - The callee function receives a set of values that are to be received by the parameters...
Post your comment