/* * nineread.c */ #include int main(void) { FILE * fp; float count; float num; // open file and read what is there if( (fp=fopen("numbers", "rb"))==NULL ) { printf("Cannot open numbers for reading!\n"); return(1); } while(!feof(fp)) // feof evaluates true when fp==EOF { fread(&num, sizeof(float), 1, fp); // read from fp, // 1 element size of float // store at address of &num if(!feof(fp)) // check for EOF pointer before printing. { printf("%.7f\n",num); } } fclose(fp); return 0; }