Chapter Contents |
Previous |
Next |
strerror |
Portability: | ISO/ANSI C conforming |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
EXAMPLE | |
RELATED FUNCTIONS | |
SEE ALSO |
SYNOPSIS |
#include <string.h> char *strerror(int errnum);
DESCRIPTION |
strerror
maps the error number in
errnum
to an error
message string.
The message returned by
strerror
provides much less information than the library-generated
message for an error. For instance, the result of
strerror(ERANGE)
is "math function value out of bounds," while the
library message for this error includes the name and arguments of the failing
function.
RETURN VALUE |
The return value is a pointer to a message describing the error number.
EXAMPLE |
#include <stdio.h> #include <string.h> #include <errno.h> #include <lclib.h> main() { FILE *f; char *filename; quiet(1); /* Suppress library messages. */ f = fopen(filename, "w"); /* Provide error message if open fails. */ if (!f) printf ("Open failed. %s\n", strerror(errno)); }
RELATED FUNCTIONS |
SEE ALSO |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.