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.