VS求单链表长度代码发生错误

#include <stdio.h>
#include <stdlib.h>
typedef int DataType;
typedef struct
{
DataType data;
struct Node* next;
}Node;
void InitNode(Node* first) //初始化单链表
{
first = (Node*)malloc(sizeof(Node));
first->next = NULL;
}
void CreaNode(Node* first,DataType n) //头插法创建单链表
{
Node* p;
for (int i = n; i > 0; i--)
{
p = (Node*)malloc(sizeof(Node));
p->data = i;
p->next = first->next;
first->next = p;

}

}
int ListLength(Node* first)
{
Node * p;
int j = 0;
p = first->next;
while (p!= NULL)
{
p = p->next;
j++;
}
return j;
}
int main()
{
int n;
int e;
Node E;

printf("input n:");
scanf("%d", &n);

InitNode(&E);
CreaNode(&E, n);
e = ListLength(&E);
printf("单链表的长度:%d", e);
return 0;

}

img

修改处见注释,供参考:

#include <stdio.h>
#include <stdlib.h>
typedef int DataType;
typedef struct node //修改
{
    DataType data;
    struct node* next;//struct Node* next; 修改
}Node;
void InitNode(Node* first) //初始化单链表
{
    //first = (Node*)malloc(sizeof(Node)); 修改
    first->next = NULL;
}
void CreaNode(Node* first,DataType n) //头插法创建单链表
{
    Node* p;
    for (int i = n; i > 0; i--)
    {
        p = (Node*)malloc(sizeof(Node));
        p->data = i;
        p->next = first->next;
        first->next = p;
    }
}
int ListLength(Node* first)
{
    Node * p;
    int j = 0;
    p = first->next;
    while (p!= NULL)
    {
        p = p->next;
        j++;
    }
    return j;
}
int main()
{
    int n;
    int e;
    Node E;

    printf("input n:");
    scanf("%d", &n);

    InitNode(&E);
    CreaNode(&E, n);
    e = ListLength(&E);
    printf("单链表的长度:%d", e);
    return 0;
}