Gets an internal error message.
Include
<string.h>
Prototype
char *strerror(int errcode);
Argument
errcode |
Return Value
Returns a pointer to an internal error message string corresponding to the specified
error code errcode
.
Remarks
The array pointed to by strerror
may be overwritten by a subsequent call
to this function, so it is not thread safe.
Example
See the notes at the beginning of this chapter or section for
information on using printf()
or scanf()
(and other functions reading and writing the stdin
or
stdout
streams) in the example code.
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <errno.h>
int main()
{
double result, x=-9.0;
result = log(x);
if(errno)
printf("Log generated %s\n", strerror(errno));
else
printf("Log of %g is %g\n", x, result);
}
Example Output
Log generated Mathematics argument out of domain of function