Question

I tried to initialize a doubly linked list wich contains dummy nodes inside another doubly linked list (also with dummy nodes). For example, a node in the list of students has many friends stored in a linked list inside that node. Here's my code:

As I tried to compile it, it gave me this: warning: assignment from incompatible pointer type. it appeared on the lines that i put a comment on. Please help. ^^

Edit: Thanks The Platypus!

Was it helpful?

Solution

You are assigning a pointer of type "friendt" to "friendh".

newNode -> friendh -> next // is a pointer of type friendh. You are assigning it a pointer of type friendt.

You're doing the opposite in the next line. Assigning friendh to friendt.

Assuming both your structs do the same thing, keep one struct or change the type of pointer in your struct to reflect your code. I.e. Change frndh* next to frndt* next and the same with the other struct

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top