typedef struct node{
int data;
struct node *next;
} Node, *NodePtr;
int main(…){
NodePtr firstNode = NULL;
…
}
NodePtr insertAtHead(NodePtr head, int data) {
/* create and fill the new node*/
NodePtr newNode = (NodePtr)malloc(sizeof(Node)); /*check that malloc does not return NULL, if yes – output an error and exit */
newNode->data = data;
newNode->next =NULL;
/* add it to the beginning of linked list*/
if (firstNode==NULL) /*linked list is empty*/
firstNode=newNode;
else {
newNode->next = firstNode;
firstNode = newNode; }
return firstNode; }
I received this code to base my homework on. I'm having issues passing the node pointer (firstNode). I get an error: conflicting types for 'insertAtHead'. I do see what I think is a problem in the definition. The first node is called head but everwhere else its called firstNode. I did make that change, I'm just lost as to how to pass this pointer. Just to show the original code we were given, I posted the code directly from the lecture notes. Thanks for the help in advance.