【发布时间】:2016-07-17 16:06:41
【问题描述】:
void push(struct node* head,int data)
{
struct node* newnode=(struct node*)malloc(sizeof(struct node));
newnode->data=data;
newnode->next=head;
head=newnode; //it doesnt work
}
此代码无效;发生的错误不是语法错误。
【问题讨论】:
-
那么是语法错误还是不是语法错误?您需要将参数声明为
struct node** head,并将最后一条语句更改为*head=newnode。 -
head的更改不会在push函数之外可见,我想这正是您想要的。 -
code is not working 意味着很多,请指出你的错误。
-
代码取自一本书..作者假设此代码不起作用
-
@isedev 为什么它不可见?