C String Functions - C strerror






char *strerror(int errnum );

Searches an internal array for the error number errnum and returns a pointer to an error message string.

Returns a pointer to an error message string.

Parameter

This function has the following parameter.

errnum
Error number.

Return

A pointer to the error string describing error errnum.

Example


#include <stdio.h>
#include <string.h>
#include <errno.h>
/*from  ww w  . ja  v  a  2 s. com*/
int main (){
  FILE * pFile;
  pFile = fopen ("unexist.ent","r");
  if (pFile == NULL)
    printf ("Error opening file unexist.ent: %s\n",strerror(errno));
  return 0;
} 

The code above generates the following result.