Closing a file
All the file must be closed after the file operations. The file can be closed using the following syntax.
Syntax:
object.close();
ex.obj.close();
End of file
Detecting of the end of file condition is necessary for preventing any further attempt to read data from the file. This can done using the following statement
while(great)
An ifstream object, such as great, returns a value of 0 if any error occurs in the file operations including the end of file condition. Thus, the while loop terminates when great returns a value of zero on reaching the end of file condition
No comments:
Post a Comment