G
gamehack
Hello all again,
Sorry for troubling you with my problems. I've tried to implement
simple double linked lists, here's my structure:
struct DResult {
double val;
char* title;
struct DResult* next;
struct DResult* prev;
};
I also have a typedef for struct DResult to DResult.
Then I've written a function to append an element to the list with the
following declation:
int dresult_append(DResult* list, DResult* element);
Then I used a debugger to trace down the issue with the function, so
the this code fragment inside the function:
if(list == NULL) // empty list
{
list = element;
return 1;
}
The problem is that list is updated after the assignment but after the
function returns, it goes back to NULL. I'm quite puzzled. Do I have to
use a double pointer for the list like DResult** list and then update
*list ( which a pointer to a DResult)?
Regards
Sorry for troubling you with my problems. I've tried to implement
simple double linked lists, here's my structure:
struct DResult {
double val;
char* title;
struct DResult* next;
struct DResult* prev;
};
I also have a typedef for struct DResult to DResult.
Then I've written a function to append an element to the list with the
following declation:
int dresult_append(DResult* list, DResult* element);
Then I used a debugger to trace down the issue with the function, so
the this code fragment inside the function:
if(list == NULL) // empty list
{
list = element;
return 1;
}
The problem is that list is updated after the assignment but after the
function returns, it goes back to NULL. I'm quite puzzled. Do I have to
use a double pointer for the list like DResult** list and then update
*list ( which a pointer to a DResult)?
Regards