diff --git a/du5/program.c b/du5/program.c index 6d45f9a..f93532f 100644 --- a/du5/program.c +++ b/du5/program.c @@ -8,12 +8,13 @@ struct person{ char name[30]; }; -void addElement(struct person **PersonList,int score,char *name){ +struct* addElement(struct person **PersonList,int score,char *name){ static int size = 1; - PersonList = realloc(PersonList,size*sizeof(struct person)); + struct *Personlist = realloc(PersonList,size*sizeof(struct person)); PersonList[size-1]->score = score; strcpy(PersonList[size-1]->name ,name); size++; + return Personlist; } @@ -32,7 +33,7 @@ int main(){ int score=0; int c =0; while(scanf("%d %s",&score,name)!=EOF){ - addElement(&PersonList,score,name); + PersonList = addElement(&PersonList,score,name); c++; }