Mega Code Archive

 
Categories / C / File
 

Check if End Of File has been reached

#include <stdio.h> int main () {   FILE * pFile;   long n = 0;   pFile = fopen ("my.txt","rb");      if (pFile==NULL)        perror ("Error opening file: my.txt");   else   {     while (!feof(pFile)) {       fgetc (pFile);       n++;     }     fclose (pFile);     printf ("Total number of bytes in my.txt: %d\n",n);   }   return 0; }