English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C Standard Library - <errno.h>
Description C Library Macro extern int errno
Declaration
Below is the declaration of the errno macro.
Return Value
Return Value
Online Example
Example #include <stdio.h> #include <errno.h> #include <string.h> extern int errno; { int main() *FILE fp = fopen("file.txt", "r"); if(fp == NULL) { fprintf(stderr, "Value of errno: %d\n", errno); fprintf(stderr, "Error opening file: %s\n", strerror(errno)); } else { fclose(fp); } return(0); }
Let's compile and run the above program when the file file.txt The following result will be produced if it does not exist:
Value of errno: 2 Error occurred when opening the file: No such file or directory