I am having trouble appending nodes to my linked list when the link list is NULL. In main it always prints NIL. How do I fix this. Here is my implementation of linked list node, and the create node and append node functions.
struct LL_node {
int data;
struct LL_node* next;
};
typedef struct LL_node LL_node_t;
LL_node_t* create_node(int x){
LL_node_t* node = (LL_node_t*)malloc(sizeof(LL_node_t)) ;
node->data = x;
node->next = NULL;
return node;
}
void append_node(LL_node_t* start,int x){
LL_node_t* node = create_node(x);
if(start == NULL){
start = node;
return;
}
LL_node_t* nodes = start;
while(nodes->next != NULL){
nodes = nodes->next;
}
node->next = create_node(x);
}
int main(void) {
LL_node_t* head = create_node(5);
LL_node_t* nodes = NULL;
append_node(nodes,3);
printf("%p\n",nodes);
return 0;
}