First, I define a structure to implement linked list:
typedef struct node
{
int data;
struct node *next;
} Node;
Then, I have to insert an element into the linked list. And I cannot finish this part.
A example from my lecture notes tells me, when we insert an element, we should do something like that:
Node a, c; // originally
Node b; // insert-element
b->next = &c;
a->next = &b;
However, I have to declare a Node to implement it. But, here is my situation: I don't know the input size, maybe I have to insert 60 elements, or maybe I just have to insert 2 elements. What is the solution?
And another small, stupid problem, is there it any different between a->next
and a.next
?