Originally Posted by
Cgmgator
Of course...its a flush function from a scanf!!! It's during the scanf!!! What is it looking for during the scanf???
Say for example you're looking for two integers...
Code:
if (fscanf(File,"%d %d",&a,&b) == 2)
++count;
If you check the return value of fscanf() you will get the number of successful conversions... anything but 2 would tell you not to increment your array pointers and carry on to the next line.
A variant of scanf(), sscanf() can be used with fgets() to break out a line at a time and then convert from the line...
Code:
do
{ fgets(buff, buffsize,file);
if (sscanf(buff,"%d %d",&a[count],&b[count]) == 2)
count++
} while (! feof(file));
Of course you will need to flesh this out with error checking and bounds checking, but the general concept is there.