Should I call the function ferror() after each manipulation with the flow of input / output? For example, when we read a file with integers - after each reading. Or it would be more rational to read the file to the end, and then check for an error.

    1 answer 1

    When and how often to check the error depends on the problem being solved. If you need to identify the problem as soon as possible - check after each operation. If the test suffers, then you can postpone it if it gives the expected performance gain. In any case, you must additionally make sure that there will be no problems with the further use of the file, if the previous operation has already ended with an error.