<errno.h> C Standard Library

The errno.h is a header file in the standard library of C programming language which defines a integer variable errno(short for error number) for reporting the cause of error through error codes stored in errno.

When program startup, the value stored in errno is zero. Other library functions can set errno to some positive value to report a specific error condition. Any library function can modify the state of errno before returning, irrespective of whether they detected an error or not.

The errno macro expands to an lvalue of type int containing the most recent error code.We can also modify the value of errno as per out program logic.

The errno.h header file also defines a set of macros that represent the error codes that expand to integer constants.

Errno Library Macros

Macro Description
errno This is the macro set by system calls as well as library functions for reporting the cause of error.
EDOM This macro represents domain error for a function call, in which an input argument outside the function's domain is passed(For Example log(-10)).
ERANGE This macro represents range error, in which either the input argument or result of the function is outside a function's range.
EACCES This macro represents an error when a file cannot be opened for reading.