I am having issues with trying to build a student record. The `struct` has four variables which are `id`, `name`, `age`, and `GPA`. I am supposed to read in a file and dynamically allocate memory for a new student `struct` which is suppose to hold a data set (student record). Then finally I'm supposed to print the total number of students that were successfully created from the file, `average age` (as float or double), and `average GPA` (as float or double). As you can see I am very lost and would appreciate any help in coding this project. Will be forever grateful! Here is what I have so far:

```
#include <stdio.h>
#include <stdlib.h>

typedef struct student
{
    int id;
    char name[255];
    int age;
    float gpa;
}student;

int makeStudent(FILE *fpin, student *students)
{
    int num_Students = 0;
    int rowNum = 0;

    students = (student *)malloc(sizeof(student) * 50);

    if((fscanf(fpin, "%d", students->id) < 0))
    {
        printf("Cannot create student record from file row # %d: id is invalid", rowNum);
        exit(EXIT_FAILURE);
    }

    if((fscanf(fpin, "%s", students->name) != 1))
    {
        printf("Cannot create student record from file row # %d: name is invalid", rowNum);
        exit(EXIT_FAILURE);
    }

    if((fscanf(fpin, "%d", students->age) < 0))
    {
        printf("Cannot create student record from file row # %d: age is invalid", rowNum);
        exit(EXIT_FAILURE);
    }

    fscanf(fpin, "%d", students->gpa);
    if(students->gpa < 0.0 || students->gpa > 4.0)
    {
        printf("Cannot create student record from file row # %d: GPA is invalid", rowNum);
        exit(EXIT_FAILURE);
    }
    num_Students++;
    rowNum++;
    return 1;
}

int main()
{
    FILE *fpin;
    char name[255];
    int size = 0;

    fpin = fopen("student.txt", "r");

    student studentRecord[255];
    while(fgets(name, 255, fpin) != NULL)
        printf("%s", name);

    /*while(1)
    if(!makeStudent(fpin, &studentRecord[size]))
    break;
    ++size;
    if(fpin == NULL)
    {
    perror("Error while opening the file.\n");
    exit(EXIT_FAILURE);
    }
    */

    fclose(fpin);
    return 0;
}

```

FILE DATA BELOW:

```
1
Bob Smith
24
3.5
2
Jill Williams
23
3.6
3
Tom Jones
32
2.4
4
Julie Jackson
21
3.1
5
Al Brown
23
3.35
6
Juan Garcia
22
3.4
-7
Melissa Davis
20
3.2
8
Jack Black
44
1.1

```