Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
C Library
cassert (assert.h)
cctype (ctype.h)
cerrno (errno.h)
cfloat (float.h)
ciso646 (iso646.h)
climits (limits.h)
clocale (locale.h)
cmath (math.h)
csetjmp (setjmp.h)
csignal (signal.h)
cstdarg (stdarg.h)
cstddef (stddef.h)
cstdio (stdio.h)
cstdlib (stdlib.h)
cstring (string.h)
ctime (time.h)
cerrno (errno.h)
errno


errno

macro
<cerrno>
int

Last error number

This macro expands to a modifiable lvalue of type int, therefore it can be both read and modified by a program.

errno is set to zero at program startup, and certain functions of the standard C library modify its value to some value different from zero to signal some types of error. You can also modify its value or reset to zero at your convenience.

The same header that declares errno (<cerrno>) also declares at least the following two macro constants with values different from zero:

macromeaning when errno is set to this
EDOMDomain error: Some mathematical functions are only defined for certain real values, which is called its domain, for example the square root function is only defined for non-negative numbers, therefore the sqrt function sets errno to EDOM if called with a negative argument.
ERANGERange error: The range of values that can be represented with a variable is limited. For example, mathematical functions such as pow can easily outbound the range representable by a floating point variable, or functions such as strtod can encounter sequences of digits longer than the range representable by an int value. In these cases, errno is set to ERANGE.

In C++, errno is always declared as a macro, but in C compilers it may also be implemented as an int object with external linkage.