> i was suppose to use for loop nested inside a while(!EOF) loop and was not suppose to use struct or anything else beside basic looping stuff
Well in your other thread -> help with parallel array
while(!EOF)
Just isn't going to do what you want it to do.
EOF is a numeric constant (usually -1, also equivalent to 'true'). So saying !EOF is like saying 'false', so your loop does nothing.
Perhaps you should have
Code:
while ( i< NUM_PATIENT && fscanf(spData,"%d %d %d", &ID[i], &maxHR[i], &age[i]) == 3 ) {
fprintf(spData,"%d %d %d", ID[i], maxHR[i], age[i]);
i++;
}
Or (satisfying the assignment, but not very safe)
Code:
while ( i< NUM_PATIENT && fscanf(spData,"%d %d %d", &ID[i], &maxHR[i], &age[i]) != EOF ) {
fprintf(spData,"%d %d %d", ID[i], maxHR[i], age[i]);
i++;
}