C Standard Libraries C++

clearerr()

Declaration

void clearerr(FILE* qpStream);

Description

This function clears all error indicators in the qpStream object and the end-of-file condition.

Example

#include <cstdio>

int main()
{
    // Read from the output stream to create an error.
    getc(stdout);
    // Verify that the stream has an error.
    if (ferror(stdout)) {
        perror("Error in stdout");
    } else {
        printf("No error in stdout\
");
    }
    // Clear the stream
    clearerr(stdout);
    // Verify that the error was cleared.
    if (ferror(stdout)) {
        perror("Error in stdout");
    } else {
        printf("No error in stdout\
");
    }
    return 0;
}

Output

clearerr() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.