How to clear file error in C++ by using clear() function?

While doing Input/Output operations on a binary or a text file you may encounter errors. In some situations you have to clear these errors before continuing the regular operation of the program. A clear() function is used to clear the errors in the C++ program.

Syntax of clear() function:

void clear(iostate flags=ios::goodbit);

Leave a Reply