It is used to display the error no
#include <stdio.h>
#include <errno.h>
extern int errno;
int main () {
FILE * fp;
fp = fopen ("filedoesnotexist.txt", "rb");
if (fp == NULL) {
fprintf(stderr, "Value of errno: %d\n", errno);
} else {
fclose (fp);
}
return 0;
}
To display error message use
strerror(errno) in printf
or
perror("message to be displayd before error");
0 comments:
Post a Comment