I need help with implementing the prev pointer logic part of a doubly linked list.
Basically, I'm in the middle of constructing a Linked List, which at the moment is singly linked. I have added the necessary struct node *prev; to my Struct, so that I can have both next pointers and previous pointers in each node within the list. But now I've hit a wall, and really don't know how to implement the *prev pointer within my code.
I'm not looking for exact solutions, really just a push in the right direction.
typedef struct L {
char val;
struct L *next;
struct L *prev;
} List;
List *insertList(char val, List *t1 );
List *createList(void);
int main(void) {
List *z = createList();
while ( z != NULL ) {
printf("%c", z->val);
z = z->next;
}
return 0;
}
List *createList(void) {
List *h = NULL;
char c;
do {
c =(char)getchar();
h = insertList(c, h);
}while(c != '.');
return h;
}
List *insertList( char val, List *t1) {
List *t = calloc(1, sizeof( List ));
t->val = val;
t->next = t1;
return t;
}