Deallocating memory for a linked list
i am trying to deallocate the memory for i linked list i allocated using malloc. but i cannot seem to clear the nodes.
here is the relevant parts of my program:
This is where my structure 'node' is created.
struct node *next;
This part is assigning values to each variable in the structure.
struct node* mknode(char depstat, char arrstat, int dtime, int atime, int check)
struct node* np;
np=(struct node*)malloc(sizeof(struct node));
I have tried to deallocate using this code(this is the part where i am sure it is going wrong)
struct node *n2;
for(number=1; number<=check; number++)
and i call the function using this line
the first node in the linked list is 'n_start'
check is the number of nodes in the list
i know that the nodes are all being created properly so that part is ok.
and how can i check that the mmory is deallocated?can i use a simple printf of what should be deallocated?(btw: i am using OSX Tiger and Xcode if that makes a difference)
thank you all very much