From 5f6f2ebd1ed70fa8fe02184246c54ded9dab8c75 Mon Sep 17 00:00:00 2001 From: Bohdan Yanchyk Date: Thu, 9 Apr 2020 19:41:19 +0000 Subject: [PATCH] =?UTF-8?q?Aktualizovat=20=E2=80=9Edu5/program.c=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du5/program.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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++; }