중간에 주석으로 말 써놨음




#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct student {
   int id;
   char name[20];
    int score[4];
   struct student *next;
};


int main()
{

   int count = 0, id,sc[4];
   char name[20],line[200];
  
   struct student *p, *head = NULL, *cur=NULL;
   printf("학번과  이름을 입력하세요\n");
   fgets(line, 200, stdin);
   while (fgets(line, 200, stdin) != NULL) {
       sscanf(line, "%d %s %d %d %d %d", &id, name,
               &sc[0],&sc[1],&sc[2],&sc[3]);
      p = (struct student *) malloc(sizeof(struct student));
      if( head=NULL)
         head = p;
      else
// 여기쯤에 뭔가 넣어야 하는데

//      cur->next = p;
     
  //    cur=p;
        

      if (p == NULL) {
         perror("malloc");
         exit(1);
      }


      p->id = id;
      strcpy(p->name, name);  
      p->next = head;
        for(int i=0; i< 4; i++)
           p->score[i]=sc[i];
      head = p;
   }

   printf("\n* 학생 정보*\n");
   p = head;
   while (p != NULL) {
      count++;
      printf("학번: %d 이름: %s : ", p->id, p->name);
        for(int i=0; i< 4; i++)
           printf("%6d", p->score[i]);
        printf("\n");
      p = p->next;
   }

   printf("총 %d 명입니다.\n", count);
   exit(0);
}





이거 뭐 어케 넣어야함
링크드 리스트에 읽어들인 순서대로 저장하는 코드 짜래



왜 이걸 못풀겠지 ㅅㅂ