Namespaces
Variants
Views
Actions

Error numbers

From cppreference.com
< c‎ | error

Each of the macros defined in <errno.h> expands to an integer constant expression with type int and with a unique positive value. The following constants are defined (the implementation may define more, as long as they begin with 'E' followed by digits or uppercase letters)

Defined in header <errno.h>
EDOM
Mathematics argument out of domain of function
(macro constant)
EILSEQ
(C99)
Illegal byte sequence
(macro constant)
ERANGE
Result too large
(macro constant)

[edit] Example

#include <stdio.h>
#include <math.h>
#include <errno.h>
#include <string.h>
 
int main(void)
{
    /* domain error */
    errno = 0;
    printf("log(-1.0) = %f\n", log(-1.0));
    printf("%s\n",strerror(errno));
    printf("\n");
 
    /* pole error         */
    /* same for log(-0.0) */
    errno = 0;
    printf("log(0.0)  = %f\n", log(0.0));
    printf("%s\n",strerror(errno));
 
    return 0;
}

Output:

log(-1.0) = nan
Numerical argument out of domain
 
log(0.0)  = -inf
Numerical result out of range

[edit] See also

macro which expands to POSIX-compatible thread-local error number variable
(macro variable) [edit]
displays a character string corresponding of the current error to stderr
(function) [edit]
returns a text version of a given error code
(function) [edit]