Hi
I am totally new to C programming (been using java for about 1 year) and have a question about pointers/linkedLists. So what i am trying to do is create a linked list and insert a new node as the head of the list...below is my code:
The error I am getting is
"list.c: In function ‘insertHead’:
list.c:25: error: incompatible types when assigning to type ‘int’ from type ‘struct node’"
I'm really unsure how I would assign the value of a node received as a parameter in the insertHead() function to a new node that I am creating. Thank you very much for any help :).
struct node* createNode(int d){
struct node* newNode;
newNode = malloc(sizeof(struct node));
newNode->data = d;
newNode->next = NULL;
return newNode;
}
void insertHead(struct node **headRef, struct node *n){
struct node* newNode = malloc(sizeof(struct node));
newNode->data = *n;
newNode->next = *headRef;
*headRef = newNode;
}