#include #include // This simple program reads 20 numbers from the file ints.txt and prints them. // The program has one critical flaw: it assumes (correctly) that the file // has 20 numbers stored in it. It does not handle the end of file (EOF) at all. // 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<=20; i++) { fscanf(fp, "%d", &num); printf("%d\n", num); } fclose(fp); } system("pause"); }