i have a function to create a circular list, i am having issues compiling, not sure if it is syntax, appreciate if someone can help.
void CreateCircularList(struct node** listRef, struct node** tailRef)
{
Push(&*listRef, "String 1");
*tailRef=*listRef;
Push(&*listRef, "String 2");
Push(&*listRef, "String 3");
Push(&*listRef, "String 4");
*(tailRef->next)=*listRef;
}
the compiler flags an error in the last line:
"Member reference base type 'struct node*' is not a structure or union"
Any ideas why ? thanks
You probably want
(*tailRef)->next = *listRef;
as the last assignment.
You cannot write tailRef->next
since tailRef
is a pointer to a pointer.
I also suggest just coding Push(listRef, "Some string");
instead of your Push(&*listRef, "Some string");
for readability reasons.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With