I am now a python programmer and I started my carrier with C. After two years I thought to study data structures in C again.
Forgive me asking such a silly basic question, but I can't help thinking the fact that can't we mutate a pointer holds a NULL value, by passing it to a function?
void insertn(node* noo, int i){
node* no=malloc(sizeof(node));
no->i=i;
no->next=noo;
noo=no;
}
int main()
{
node* o=NULL;
insertn(o,10);
printf("%d\n",o->i);
return 0;
}
The problem in this code is that o
's value is always NULL, it doesn't change in the function.
Why is that, can't we change a NULL
pointer in another function?