Help with file loop

Hi im writing a code that opens a file and grabs information. Im having trouble with my forloop in the function void fillArray(FILE *fptr, char *k);. So far I can grab the string "Michael and the number next. But in my loop I want to grab the numbers after 3. Eventually I will add these numbers up.
The file im opening contains.

Michael
3
100
100
100

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <stdio.h>
#include <stdlib.h>


FILE * openInputFile();
void readName(FILE *fptr);
void fillArray(FILE *fptr, char *k);

int main()
{

FILE * fptr = NULL;

fptr = openInputFile();

readName(fptr);

fillArray(fptr, "assignments");

fclose(fptr);

}

FILE * openInputFile()

{
    char filename[100];
    FILE * fptr;

    do{

    printf("Enter the file name:");

    fptr = fopen("C:\\Users\\Michael\\Desktop\\mike.txt", "r");

    if (fptr == 0)
        {
            printf("Failed to open %s.\n", filename);
        }

    }while(fptr == 0);

    return fptr;
}

void readName(FILE *fptr)

{
    char fileLine[100];

    printf("\n\nName:");
    if(fgets(fileLine, 100, fptr) != NULL)
    {
    puts(fileLine);
    }
}

void fillArray(FILE *fptr, char *k)

{
    int i;
    float f, d;

    fscanf(fptr, " %f", &f);

    for(i = 0; i < f; i++)
    {
        printf("\nScore for %s %d:", k, i+1);
        fscanf(fptr, " %f", &d);
    }
    printf("\n\n");
}
Topic archived. No new replies allowed.