I hope someone can help me. I am in the process of working on a linked list project. When I do everything in main (commented out right now) it works nodes are created etc... However when I do it in a function it doesn't work, I get a core dump. Am I doing something wrong with passing the pointers as parameters??
Thanks in advance,
Branden
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct node{
int number;
struct node *next;
struct node *prev;
} NODE;
void createlist(NODE *head, NODE *current, int number)
{
head = (NODE*)malloc(sizeof(NODE));
current = head;
current->number = 15;
current->next = current;
current->prev = current;
}
int main()
{
NODE *head = NULL;
NODE *current = NULL;
//create the first node
//head = malloc(sizeof(NODE));
//current = head;
//current->number = 15;
//current->next = current;
//current->prev = current;
//end first node creation
createlist(head, current, 15);
printf("%i\n", current->number);
return 0;
}