On this line:
*head->prev=temp;
The ->
operator has higher precedence than the *
operator, so it parses as:
*(head->prev)=temp;
This is invalid because head
is a pointer-to-pointer-to-struct, not a pointer-to-struct. You need to add parenthesis to force the *
operator to apply directly to head
:
(*head)->prev=temp;
Also, don’t cast the return value of malloc
as it can mask other errors in your code.
solved *head’ is a pointer; did you mean to use ‘->’? Why am I getting this