I'm building a single linked list and trying to allocate memory for it like so
struct node *new_node = (node*) malloc(sizeof(node) * 5);
so enough memory for 5 nodes. Now accessing the first node via:
new_node->data = new_data;
is fine, but when I go to link another node to new_node->next, I forget how I say that the new node is a part of the memory I've already allocated. I don't want to malloc each time I want a new node as for the purposes of the assignment I'm working on, we want to malloc as infrequently as possible.
Any clues greatly appreciated, this far I haven't been able to find what I need on the great wide webs.
John!
malloc()
. – Quentin