It's easier to pinpoint a problem in this procedure if you use fgets() to get a line from the file and sscanf() on the line to extract your data. So for example:
Code:
char line[64]; /* should be long enough for this, right? */
float data;
FILE *fh; /* obviously this should be fopend, etc. */
while ((fgets(line,8,8,fh))) {
sscanf(line, "%f", &data);
}
The outer layer of brackets is a truth test the same as this:
Code:
while (fgets(line,8,8,fh)!=NULL) {
Since fgets returns NULL at end-of-file.
Once you have everything worked out you can always change it back to the straight fscanf().
For counting the lines add this to the loop: