下のポログラムを参考にして名前もホームランの本数も入力できて何人分も追加できるポログラムを教えてください。ポインター使用でお願いします。
#include <stdio.h> #include <malloc.h> #include <string.h>
struct MJlist {
char name [20]; int homerun;
struct MJlist *pointer;
};
int main (void){
struct MJlist *hd,*p1,*p2; int sum =0;
p2=(struct MJlist*)malloc(sizeof(struct MJlist));
strcpy(p2->name,"ICHIRO");
p2->homerun=10;
p2->pointer=NULL;
p1=(struct MJlist*)malloc(sizeof(struct MJlist));
strcpy(p1->name,"MATUI");
p1->homerun=15;
p1->pointer=NULL;
hd->pointer=p1;
p1->pointer=p2;
hd=(struct MJlist*)malloc(sizeof(struct MJlist));
strcpy(hd->name,"Nomo");
hd->homerun=5;
hd->pointer=NULL;
}