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.
This function has the following parameter.
A pointer to the error string describing error errnum.
#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.