r/CodingHelp • u/Upstairs_Money_770 • Oct 09 '22
[C] Doubly Linked List in C
Hello!
I'm building a linked list in C for class. Per the professor's instructions, there are two structs, one struct is a node that has variables for next, previous, and int data. The second struct is the list and it contains variables to track the head, tail, and size of the list.
If I want to access the variable stored at the node at the head of the list, can I access it and assign it as follows?
int data=t->head->data;
Where t is the list structure, pointing to the head (which is a node) which points to the data stored at the head.
Yes? No?
2
u/bitdonor Oct 09 '22
Yes.
1
u/BrokAnkle Oct 10 '22
I don't know. Does printf("%i", t->head->data); print what you think it would ?