I am moving from Java to C and I am currently trying to design a linked list. In order to do this, I created a "node" structure which has a integer "val" attribute and a "dummy_element *next" attribute which is just a pointer to the next object. In the very beginning of the program, when it first starts running, no nodes should exist in memory, so I created a "Init_node()" function which creates a node called "first" and makes two external pointers "linked_head" and "linked_tail" point to the "first" node. Here is the relevant code:
typedef struct dummy_element {
int val;
struct dummy_element *next;
}node;
node *linked_head;
node *linked_tail;
node *traversal
void Init_node(){
node first;
first.val = NULL;
first.next = NULL;
linked_head = &first;
linked_tail = &first;
}
The whole point of the Init function is to initialize an empty node just so the pointers have something to point to. However, I keep getting the error "assignment makes integer from pointer without a cast" at first.val = NULL. Im not sure how to get around this error.