Use perror function to map error message
Syntax
C perror function has the following syntax.
void perror(const char *str);
Header
C perror function is
from header file stdio.h
.
Description
C perror function maps error message to the global variable errno and outputs that string to stderr.
Example
Map error message with C perror function.
#include <stdio.h>
#include <stdlib.h>
/* ww w. j a v a 2 s.co m*/
int main(void)
{
perror("File error ");
}
The code above generates the following result.