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);
      ...
   }
programming/c-cpp/cfilemanipulation.txt · Last modified: 2018-06-21 19:48 (external edit)
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0