Guest_imported
New member
- Jan 1, 1970
- 0
regarding the bit of code below, which I posted before and recived help with, Russ also pointed out the following (which I was aware of and had fudged around):
----snip*-----
Also, you have a common error in your loop where you use the feof() function to test for end of file at the top. The problem is that feof() doesn't evaluate the stream passed to it, so it won't detect end of file until the code inside the loop has already detected it, in this case fscanf(). This will cause you to read the value of EOF into your variables, if this conversion is possible.
---snip-----
no amount of messing with while or do whiles can solve this problem properly. Any suggestions.
Thanks
tom
===snip file reading code =====
while(!feof(textfile))
lstptr = (INPUT*) malloc(sizeof(INPUT));
fscanf(textfile,"%s %s %s %s", lstptr->field0, lstptr->field1, lstptr->field2, lstptr>field3);
rcdCtr++;
lstptr->next = endOfInputPtr
endOfInputPtr = lstptr;
} fclose(textfile);