由于某种原因,我无法打印整个链表。我哪里会出错?请帮忙。提前致谢。
列表的基本结构。
struct node
{
    int num;
    struct node *next;
};
typedef struct node *list;
主功能。
int main()
{
    int i, j, k, l;
    list head = NULL, start = NULL, temp, p;
    printf("Enter the number of nodes in the list: ");
    scanf("%d", &k);
链表的形成。
    for(i=0;i<k;i++)
    {
        if (i==0)
        {
            start = (list) malloc(sizeof(struct node));
            start->num = i;
            head = start;
            head->next = NULL;
        }
        else
        {   
            temp = (list) malloc(sizeof(struct node));
            temp->num = i;
            head->next = temp;
            head->next = NULL;
        }
    }   
打印链表。
    p = start;
    while(p != NULL)
    {
        printf("%d", p->num);
        p = p->next;
    }
    return 0;
}