Question 8 of 1412 points

Question 8 · 12 points

Dynamic file loader

Implement load_students to read an unknown number of students from a text file.

typedef struct {
    int id;
    char name[32];
    double mark;
} student_t;

student_t *load_students(
    const char *filename,
    size_t *count
);

Your implementation must dynamically grow the array using realloc, store the number of students in *count, check file and allocation errors, close the file before returning, and free all allocated memory if an error occurs. State the input line format you assume.

Your response

Your answer

0 words