perror

Header: <stdio.h>

Prints a textual description of the error code currently stored in the system variable errno to stderr.

# Declarations

void perror( const char *s );

# Parameters

# Return value

(none)

# Example

#include <stdio.h>
 
int main(void)
{
    FILE *f = fopen("non_existent", "r");
    if (f == NULL) {
        perror("fopen() failed");
    } else {
        fclose(f);
    }
}

# See also