📜  读取文件 - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:35.684000             🧑  作者: Mango

代码示例3
#include 
#include 

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;
}