#include #include // This simple program reads 25 numbers from the file ints.txt and prints them. // The file has only 20 numbers stored in it. // // The program checks for the end of file (EOF) but it is still not perfect. // The next sample program fixes this. int main() { FILE* fp; if( (fp = fopen("ints.txt", "r")) == NULL) { printf("File not found!\n"); } else { int i, num; for(i=1; i<=25; i++) { int res = fscanf(fp, "%d", &num); if(res == EOF) printf("Reached End Of File!\n"); else printf("%2d\n", num); } fclose(fp); } system("pause"); }