How would I change this function so that it appends new nodes to the end of the list instead of at the beginning?


struct node *append(struct node *list, int data)
{
struct node *new;
new = malloc(sizeof(struct node));
if(new == NULL) {
printf("malloc failed to allocate storage - exit\n");
exit(0);
}

new->value = data;
new->nextPTR = list;
/* headPTR is a global pointer of type struct node */
new->prevPTR = headPTR;
return new;
}