#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
int main() {
const char* filename = "d:\\example.txt";
FILE* fp = fopen(filename, "r");
if (errno == ENOENT) { // ENOENT = 2 = no file name with this name
fprintf(stderr, "Error open file");
printf(", errno = %d", errno);
exit(1);
}
return 0;
}
/*
run
Error open file, errno = 2
*/