链表打印轮到最后一个指向空指针的就该结束,可是不知道为什么进入死循环

img

img

img

头插法,最开始的链表头是指向的空指针没错啊,为什么本该循环到最开始的链表头那里就结束的循环会发生段错误,

createLink()函数是怎样的,上面图片看不到,不是打印输出的问题。
问题出在 struct Test* createLink(struct Test* head) 函数里,做了修改,供参考:

struct Test* createLink(struct Test* head)
{
    struct Test* New;
    printf("HINT:Enter 0 End!\n");
    while (1){
         New = (struct Test*)malloc(sizeof(struct Test));
         New->next = NULL;  // 修改
         printf("imput your new to node data\n");
         scanf("%d",&New->data);
         if (New->data == 0){
             free(New);
             return head;
         }
         head = insertFromHead(head,New);
    }
}