map an error number to an error message
#include <string.h> char *strerror( int errnum );
The strerror() function maps the error number contained in errnum to an error message. The messages for this function are listed in the section “The strerror () Function” in Appendix A: Implemenation-defined Behavior.
The strerror() function returns a pointer to the error message. The array containing the error string should not be modified by the program. This array may be overwritten by a subsequent call to the strerror() function.
#include <stdio.h> #include <string.h> #include <errno.h> void main() { FILE *fp; fp = fopen( "file.nam", "r" ); if( fp == NULL ) { printf( "Unable to open file: %s\n", strerror( errno ) ); } }
ANSI
All (except DOS/PM)