Why does the value of the variable 'errno' change from 2 to 22 in the following piece of code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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
0 Answers