I am trying to write a program involving structures. The program must have a function that prints the first name and last name for a given student. This function has to calculate the student's average.

Then I have to have one function that computes the course's average of all the students. It doesn't appear I am doing the function call right in lines 58 and 60


I have passed the &Grades (structure)
I have tried &Grades&t

I am screwing something up. There is one example in the book but they don't pass a structure to a function. Any help is appreciated.


grades.c: In function âmainâ:
grades.c:58: error: expected expression before âGradeâ
grades.c:60: error: âsâ undeclared (first use in this function)
grades.c:60: error: (Each undeclared identifier is reported only once
grades.c:60: error: for each function it appears in.)
grades.c: At top level:
grades.c:67: error: expected identifier or â(â before â{â token
grades.c: In function âprintcourseavgâ:
grades.c:91: error: âstudentfinalâ undeclared (first use in this function)
grades.c:94: error: invalid lvalue in assignment



Code:
#include <stdio.h>
#include <stdlib.h>

typedef  struct  Grade {
        char *firstname;
        char *lastname;
        int *grades;
} Grade; 

typedef struct Course {
        char *name;
        char *lastname;
        int *studentfinal;
} Course;

void printname ( Grade *t );

void printcourseavg ( Course *s );


int main (void){
struct Grade first;
first.firstname = "John";

struct Grade last;

last.lastname = "Doe";


struct Grade data;


data.grades = (int*) calloc(5,sizeof(int));
data.grades [ 0 ] = 78;
data.grades [ 1 ] = 87;
data.grades [ 2 ] = 85;
data.grades [ 3 ] = 86;
data.grades [ 4 ] = 85;


struct Course data1;

data1.studentfinal = (int*) calloc ( 5,sizeof (int));
data1.studentfinal [ 0 ] = 87;
data1.studentfinal [ 1 ] = 89;
data1.studentfinal [ 2 ] = 78;
data1.studentfinal [ 3 ] = 87;
data1.studentfinal [ 4 ] = 89;






printname( Grade *t);

printcourseavg(&s);

return 0;
}


void printname ( Grade *t );
{
int i;
int total;
float avg;
printf("%s\n", t->firstname);
printf("%s\n", t->lastname);

for ( i = 0; i < 4; i++ ){
        total = grades [ i ];

        }

printf("The average grade for the course is %d\n", ( float ) avg = total /4 );


}

void printcourseavg ( Course *s)  {

        int i,
        total = 0;
        float avg;

        for ( i = 0; i < 5; i++ ) {
        total = studentfinal [ i ];

        printf("The course average is %d", ( float ) avg = total / 5 );

}