0
`struct node * createLL(struct node *head)
{
int num;
struct node *new_node;
printf("enter the numbers you want to insert:\n");
printf("enter -1 to quit");
scanf("%d",&num);
while(num!=-1)
{
new_node=(struct node *) malloc (sizeof(struct node *));
new_node->data=num;
if(head==NULL)
{
new_node->next=NULL;
head=new_node;
}
else
{
new_node->next=head;
head=new_node;
}
printf("enter the numbers you want to insert:\n");
printf("enter -1 to quit");
scanf("%d",&num);
}
return head;
}`
用于为类型struct node *的链接列表创建new_node的malloc显示错误。它说“malloc没有在范围内声明”.. 我也提到了书籍..代码是一样的..无法弄清楚如何纠正错误 。Malloc函数显示错误
'malloc'应在stdlib.h中声明 - 你确定你做的#include''? –