Answers for "how to read information from a file using name in c"

C
1

read file c

#include <stdio.h>
#include <stdlib.h>

int main()
{
   int num;
   FILE *fptr;

   if ((fptr = fopen("C:\\program.txt","r")) == NULL){
       printf("Error! opening file");

       // Program exits if the file pointer returns NULL.
       exit(1);
   }

   fscanf(fptr,"%d", &num);

   printf("Value of n=%d", num);
   fclose(fptr); 
  
   return 0;
}
Posted by: Guest on January-17-2022

Code answers related to "how to read information from a file using name in c"

Code answers related to "C"

Browse Popular Code Answers by Language