这是我为链表编写的代码。基本上它只需要输入并打印它。在编译时它没有给出错误,但也没有给出输出。我没有得到这段代码有什么问题?帮帮我。
#include<stdio.h>
struct list {
int data;
struct list* next;
};
insert(struct list* node, int data)
{
node = malloc(sizeof(struct list*));
if (node == NULL)
node = data;
else
node->data = data;
node->next = NULL;
return node;
}
printlist(struct list* node)
{
if (node == NULL)
printf("Empty list\n");
while(node->next != NULL)
printf("the list contains %d", node->data);
node = node->next;
}
main()
{
struct list* NODE;
NODE = malloc(sizeof(struct list*));
insert(NODE, 3);
insert(NODE, 5);
printlist(NODE);
}