Basically I need to scan all the values from this file...which it pretty much does, but it seems to skip random ones so it ends up not lining up properly. (This is only part of what I need to do for the assignment so you are not "giving away the answer" and I still want to figure it out on my own, just need a little help figuring this one out, because I'm pretty stuck)
Here is the code:
int main()
{
FILE *fp;
char x[15];
float ID [1000];
int i=0, j=0;
float homework [1000];
float lab [1000];
float midterm [1000];
float Final [1000];
int count=0;
char headers[35];
char y;
fp= fopen("lab5_inputFile.txt", "r");
while (fscanf(fp, "%s", x)!=EOF){
if (count > 728){
fscanf(fp, "%f", &ID[i]);
printf("ID : %.1f\n", ID[i]);
fscanf(fp, "%f", &homework[i]);
printf("Homework: %.1f\n", homework[i]);
fscanf(fp, "%f", &lab[i]);
printf("lab: %.1f\n", lab[i]);
fscanf(fp, "%f", &midterm[i]);
printf("Midterm: %.1f\n", midterm[i]);
fscanf(fp, "%f", &Final[i]);
printf("Final: %.1f\n", Final[i]);
i++;
}
count ++;
}
printf("count = %d\n", count);
fclose(fp);
I only scanned the last few values to make it easier to read/debug, in the actual code I will only be skipping the headings, there's also a lot of other things I plan to change before submitting this, like I might use pointer type and malloc instead of arrays and a bunch of other things, but my main question is how to fix the problem I am having with reading from the file into the arrays.
Thanks in advance!