Here is the struct I am using for the nodes...
typedef struct
{
struct Node* next;
struct Node* previous;
void* data;
} Node;
and h
Similar to Deepu's answer, but a version that will let your code compile. Change your struct to the following:
typedef struct Node // <-- add "Node"
{
struct Node* next;
struct Node* previous;
void* data;
}Node; // <-- Optional
void linkNodes(Node* first, Node* second)
{
if (first != NULL)
first->next = second;
if (second != NULL)
second->previous = first;
}
I think the problem is there is no struct called Node, there is only a typedef. Try
typedef struct Node { ....
Defining typedef
of struct
in C is best done before the struct
declaration itself.
typedef struct Node Node; // forward declaration of struct and typedef
struct Node
{
Node* next; // here you only need to use the typedef, now
Node* previous;
void* data;
};