今天学链表有的迷糊
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct STUDENT {char name[20];
float age,chinese,math;
struct STUDENT *next;
};
typedef struct STUDENT STU;
STU *create_list();
void print_list(STU *head);
main()
{
STU *head;
head= create_list();
print_list(head);
}
STU *create_list()
{
STU *head,*p,*q;
char na[20];
head=(STU *)malloc(sizeof(STU));
q=head;
printf("输入数据\n");
scanf("%s",na);
while (strcmp(na,"over")!=0)
{
p=(STU *)malloc(sizeof(STU));
strcpy(p->name,na);
scanf("%d%f%f",&p->age,&p->chinese,&p->math);
q->next= p;
q = p;
scanf("%s",na);
}
q->next= NULL;
return head;
}
void print_list(STU *head)
{
STU *p;
p=head->next;
while(p!=NULL)
{
printf("%s%d%f%f\n",p->name,p->age,p->chinese,p->math);
p=p->next;
}
}能不能给我注释下