关于链表,帮忙看看,程序错在哪!
											 程序代码:
程序代码:#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct student
{
    int index;
    float score;
    struct student *next;
};
void
main(void)
{
    struct student *p,*q,*head;
    int k = 0,num = 0;
    head = NULL;
    printf("say something:");
    scanf("%d",&num);
    while(num != 0)
    {
        k++;
        p = new student;
        p -> index = num;
   
        printf("input score: ");
        scanf("%f",p -> score);
        p -> next = NULL;
        if(k == 1)
        {
            head = p;
        }
        else
        {
            q -> next = p;
        }
        q = p;
        printf("input the next student index:");
        scanf("%d",&num);
    }
}编译没有出错,可是输入第一个num值之后程序就崩了										
					
	


 
											





 
	    

 
	