Hi guys i've built a linkedlist library in C but am having some pointer confusion, when I call the create method below it seems to have no effect on the list that I pass into it, when it should set up the root node. Included some of the code below, hope someone can help?
So you create a linkedlist object (which is a pointer to a node) and then you pass a COPY of that pointer to the function create (because this is pass-by-value), then that COPY gets altered, and then when the function ends the COPY is destroyed.
The parameter takes an argument by value. It is a local value of the function. So when the control exits the function the local variable is destroyed. The original variable list defined in main does know nothing what was done in the function. Its value will not be changed. You should declare the parameter as a pointer to linkedlist.