+ 1

Why does the value of the variable 'errno' change from 2 to 22 in the following piece of code?

#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> int main() { FILE *fptr; errno = 0; fptr = fopen("c:\\nonexistantfile.txt", "r"); if (fptr == NULL) { perror("Error"); fprintf(stderr, "%s\n", strerror(errno)); exit(EXIT_FAILURE); } fclose(fptr); return 0; }

3rd Jan 2022, 7:39 AM
Ashwin Saseendran PC
Ashwin Saseendran PC - avatar
1 Réponse