帮我看下main函数怎样写啊(建立链表输入数据)
#include<stdio.h>#include<malloc.h>
struct student
{
int num;
char name[12];
int score;
struct student *next;
};
struct student *creat(void)
{
int i, n; struct student *head, *p, *r;
head=(struct student *)malloc(sizeof(struct student));
head->next=NULL;
r=head;
printf("请输入学生人数:\n");
scanf("%d",&n);
for(i=1; i<=n; i++)
{ p=(struct student *)malloc(sizeof(struct student));
printf("输入学生的学号:\n");
scanf("%d", &p->num);
printf("输入学生的姓名:\n");
scanf("%s", p->name);
printf("输人学生的成绩:\n");
scanf("%d", &p->score);
p->next=NULL;
r->next=p;
r=r->next; }
return(head);
}
void main()
{
struct student *p;
p=create();
}