Write a C program to attempt to open a file for reading If i
Write a C program to attempt to open a file for reading. If it can be opened, close it and return a 0. If it cannot be opened, return a 1 and quit. The filename should be an argument to your program. Use \"echo $?\" after running your program, to see the result.
Solution
#include <stdio.h>
 int main()
 {
 char s;
FILE *fpr;
 fpr = fopen(\"NEWFILE.C\", \"r\");
if (fpr == NULL)
 {
 return 0;
 }
  
   
 while(1)
 {
 s = fgetc(fpr);
 if (s==EOF)
 break;
   
 }
  
 fclose(fpr);
   
 return 1;
 }

