链表问题,大神求助,如图报错

#include
#include
#include
#define M 3

typedef struct student {
int num[8];
char name[20];
int score[M];
float average;
struct student *next;

}STU;
STU *creat(void){
STU *head, *p,*pnew;
int i,n;
head = (STU *)malloc(sizeof(STU));
if (head != NULL)
{
p = pnew = head;
for (i = 0; i < M; i++)
{
p = (STU *)malloc(sizeof(STU));

        if (p!= NULL)
        {

            printf("please input the num\n");
            scanf("%d", &p->num);

            printf("please input the name\n");
            scanf("%s", p->name);
            for (n = 0; n < M; n++)
            {
                printf("please input the score\n");
                scanf("%d", &p->score[n]);

            }
            pnew->next = p;
            pnew = p;//连接节点





        }
        else
        {
            printf("Application for memory failure");
            exit(1);
        }
    }
}
else
{


        printf("Application for memory failure");
        exit(1);

}

}//创建链表

void print(STU *head)
{
STU *p;
int i;
p = head;
while (p != NULL) {
printf("%d\t%-15s\t%f\t", p->num, p->name, p->average);
for (i = 0; i < M; i++)
{
printf("%d\t", p->score[i]);
}
}

}//输出函数
void avescore(STU *head) {
int j, sum;
STU *p;
p = head;
while (p != NULL)
{
sum = 0;
for (j = 0; j < M; j++)
{
sum += p->score[j];
}
p->average = sum / 3.0;
p = p->next;

}

}
int main(void) {
STU *head = NULL;
head = creat();
avescore(head);
print(head);

}图片说明

 p = (STU *)malloc(sizeof(STU));
p->Next = NULL: //分配内存后这里要加上

否则不能保证while (p != NULL) 这里判断是可靠的