perror

From Wikipedia, the free encyclopedia

C Standard Library headers

The POSIX error function, perror, is used in C and C++ to print an error message to stderr, based on the error state stored in errno.

Contents

[edit] History

The definition of perror was first released in Issue 1 of the System V Interface Definition.

[edit] Usage

[edit] Inclusion

C
#include <stdio.h>
C++
#include <cstdio>

[edit] Declaration

void perror(const char* prefix);

[edit] Semantics

If the parameter prefix is non-NULL, perror will first print prefix followed by a colon and a space to standard error. Then, it will print the result of strerr to standard error, followed by a newline character.

[edit] See Also

[edit] References

  1. perror by OpenGroup