// feof example: byte counter // source: http://www.cplusplus.com/ #include #include int main() { FILE * pFile; int n = 0; pFile = fopen("myfile.txt","r"); if (pFile==NULL) perror ("Error opening file"); else { while (fgetc(pFile) != EOF) { ++n; } if (feof(pFile)) { puts("End-of-File reached."); printf("Total number of bytes read: %d\n", n); } } fclose(pFile); return EXIT_SUCCESS; }