Table of Contents

C File manipulation

Open file for read

    FILE *file;
 
 
    file = fopen(argv[1],"r");
    if(file==NULL)
    {
        printf("Cannot open file %s!\n",argv[1]);
        return (EXIT_FAILURE);
    }
 
    fclose (file);
 

Read to end of file

   while (!feof(file))
   {
 
      fscanf(file,"%d",&value);
      ...
   }