errno

From cppreference.com
< c | error
Defined in header <errno.h>
#define errno /*implementation-defined*/

errno is a preprocessor macro that expands to a thread-local modifiable lvalue of type int. Several standard library functions indicate errors by writing positive integers to errno. Typically, the value of errno is set to one the error codes, listed in <errno.h> as macro constants that begin with the letter E, followed by uppercase letters or digits.

The value of errno is 0 at program startup, and although library functions are allowed to write positive integers to errno whether or not an error occurred, library functions never store 0 in errno.

[edit] Example

#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
 
int main (int argc, char **argv)
{
	int fd = -1;
	fd = open ("/dev/zer0", O_RDONLY);
 
	if (errno)
	{
		perror ("Ouuupsss");
		exit (EXIT_FAILURE);
	}
 
	close (fd);
 
	return EXIT_SUCCESS;
}

Output:

Ouuupsss: No such file or directory

[edit] See also

macros for standard POSIX-compatible error conditions
(macro constant)
displays a character string corresponding of the current error to stderr
(function)
returns a text version of a given error code
(function)