Use perror function to map error message

Syntax

C perror function has the following syntax.

void perror(const char *str);

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.





















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h