I'm still getting used to C, i'm writing a basic linear linked list. Am I correct in assuming that the best coarse of action is to create a "free list" routine.
YES, that looks good
If im allocating memory for the node, and I want to store a string in that node, I have to allocate memory for the string too right?
If your data structure was like this
Code:
struct node
{
char *str;
struct node *next;
};
Then YES you will have to allocate memory and make sure u free all those memory when u free the node.
Or if your data structure looked something like this
Code:
struct node
{
char str[25];
struct node *next;
};
Then u dont have to allocate memory for your string, cos you have already allocated memory for your string when u create a new node.
ssharish