I was suggested to build a linked list using the following struct
as a node:
typedef struct node *link;
struct node{
int item;
link next;
};
As I did not understand what the pointer operator along with this typedef
I searched for, I ended up thinking that in this case link
becomes a nickname for pointers to the node
structure. Knowing this I started to create the list based on this idea, but at the beginning I already found errors, the code is compiled correctly, but the execution window crashes right after.
Code I'm getting:
int main ()
{
link l;
l->next = NULL;
}
I suppose I'm mistakenly using the nickname of the node pointer. What is the correct way to use it?