CKTIS / C
perror — print the message corresponding to errno
perror from <stdio.h> prints a message for the current errno value to stderr, optionally preceded by your own description. It does not detect an error and returns no value.
Version: C23; repository compiler flag, production runtime not attested
Syntax
#include <stdio.h>
void perror(const char *s);perror(s) describes the current value of errno. Its declaration is provided by <stdio.h>; include <errno.h> to use errno directly. The function returns void.
If s is neither a null pointer nor an empty string, it prints that string, then : , the message, and a newline. Otherwise, it omits the prefix and separator. It writes to stderr, not stdout; the message text corresponds to strerror(errno).
Check the operation's result first: perror does not detect failure. Use it when that operation documents setting errno, before another call changes that value. The example deliberately assigns EDOM rather than triggering a real failure. The exact message text depends on the implementation.
Examples
#include <errno.h>
#include <stdio.h>
int main(void)
{
errno = EDOM;
perror("demo");
return 0;
}
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.