Hi,
I haven't programed in C for a long time and I have decieded on a simple project to get myself back into it. However, it seems mot so simple!
I want to create a list of pupil details in a number of classes. So far i've got:
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct {
char * name;
int age;
} pupil;
typedef struct {
char * name;
int num_pupils;
struct pupil ** pupils;
} class;
int main ()
{
class * class1;
class1 = (class *)calloc(sizeof(class),1);
class1->name = (char *)calloc(sizeof(char),128);
strcpy (class1->name, "Hello");
class1->num_pupils = 20;
printf ("Class %s has %d pupils\n", class1->name, class1->num_pupils);
class1->pupils = (pupil*)calloc(sizeof(pupil), 20);
}
I think i've made a mistake on the last line as this is where it fails to compile but there may be others, i'd apreciate any help on the current problem and any changes which "should" be made to the code.
Thanks for any help