Reading an array in a while not end of file loop
As part of a program, I have to read golf scores for multiple people into arrays. With the structure of the program, I have to load the array, use it to perform basic operations, and then load the next one, until the end of the input file. Here's what I have so far, where strokes[] is the array, golf is the input file, and result is the output file:
Code:
i = 1;
while(!feof(golf))
{
for(i = 1; i <= 18; i++)
{
fscanf(golf, "%d", &strokes[i]);
fprintf(result, "%d", strokes[i]);
}
i = 1;
fscanf(golf, "%d", &strokes[i]);
}
I've been using the print for now just as a test to see if the data is reading correctly. I don't know if something is missing or what, but I keep getting infinite loops. I'm new to programming, so any help would be greatly appreciated. Thanks.