I keep getting an "Assignment from incompatible pointer type" and I can't figure out why. I thought it looked right. I'm just trying to do the basics of a linked list in C.
typedef struct{
int id;
struct node *next;
} node;
node *root = NULL; // Sets up a root node when the program starts.
create nodes(int id){
if(root == NULL){
root = (node*)malloc(sizeof(node));
root-> id = -1;
node *nextNode;
nextNode = (node*)malloc(sizeof(node));
nextNode -> id = id;
root-> next = nextNode; // This line is throwing an error.
}
}
I feel like it's something simple but I can't put my finger on it...