I can't thank you enough! Your help has been invaluble for me to actually understand this whole ordeal. I really appreciate that you made me conceptualize the problem. I really feel like drawing out...
Type: Posts; User: Lax
I can't thank you enough! Your help has been invaluble for me to actually understand this whole ordeal. I really appreciate that you made me conceptualize the problem. I really feel like drawing out...
Okay Im getting it to work!! This is how the code looks like now:
#include "stdio.h"
#include "stdlib.h"
typedef struct node
{
struct node *prev;
Also this might be a pointer arthmetic question, but how would I access the next pointer of the node before the one im inserting. I assume it I would do it by using the tail pointer before I...
Okay I see but just to be sure: This node->prev = list->tail does establish this connection : Screenshot - de7495e8b6eb0a7764d9f138c3413d09 - Gyazo (the one the red arrow is pointing at) if it is...
Yea that is true. I actually tested myself and when I saw that I only got a 6 from my printlist I thought it was because the head pointer didnt change so I just changed the list->head to list->tail...
Oh I think by sheer coincidence I wrote my most recent message just as you posted this reply. I think I managed to understand and implement it.
I COME BEARING GOOD NEWS!!!
So after taking what you said to heart I tried to implement my foundings I wrote in my two most recent posts.... AND IT WAS A SUCCES!!
This is what my current code...
Here is another attempt. (I'll go with my intuition here but with your feedback in mind)
first line https://gyazo.com/e7acefb1141b33d7d31bd662ed9c0ed1 now the prev pointer is pointing to a NULL...
Oh this makes sense I will have another go at this.
Ah I see so node->prev = list->tail; makes the prev pointer of the that node point to whatever the list points at.
I don't really...
I Totally missed these replies. This does give me some more context. If I would redraw the steps again it would look this in my mind:
We start like this again: Screenshot -...
Thank you for such a wonderful reply! Im so thankful you are trying to get me to understand the core concept instead of just giving me the answer, I really do so thanks a ton!
I followed your...
Here is the InsertTail
int insertTail(list_t *list, node_t *node)
{
node->prev = list->tail;
node->next = NULL;
list->tail = node;
Yea that makes sense. I have seen plenty other examples where that solution is used.
If I may ask, is my previous assumptions correct? I feel like there is still something wrong with either my...
So I compiled what I wrote and while I didnt get any errors after some fixes.
This is what I got so far:
node->prev = list->tail; // Copies the adress of the tail of the previous node into the...
A right that makes sense since they are not the sama data type. I have to be honest here all these pointers are a bit confusing to me but asking these question is really making it easier for me to...
I have now made a couple of changes to my program to try and get a greater understanding of pointers, aswell as memory allocation. I have now implemented a previous pointer to make it a doubly linked...
Thanks for the reply!
Ohh I see that makes sense. So if I would like to acess that point in memory, (but not dereference) I would just store the adress in another variable?
list_t *list2;...
After thinking things through a bit there is something here I dont quite fully understand.
This bit here:
list_t *createList(void)
{
list_t *list = malloc(sizeof(*list));
if (list)...
Thank you so much for this. This cleared a lot that I was confused about. What you said about memory leak really made a lot of sense to me. I really appreciate that you took the time to explain this...
Hello,
I'm trying to implement an insert function to my linked list but when I try to print the values I only get what I assume is memory adresses. Why is this the case? I have also noticed that...
Oh that do make a lot of sense! Thank you for taking the time to answer :)!
Hello!
So I'm currently just experimenting with linked lists to get a better understanding of it aswell as on pointers. However, I'm afraid there is something im missing. I'll just post my code...