#include <stdio.h>
#include <stdlib.h>
typedef struct{
int data;
struct Node* next;
}Node;
Node* head;
void AddEntry(){
int x;
Node* temp;
temp = head;
while(temp != NULL){
temp = temp->next;
}
Node* temp1 = (Node*)malloc(sizeof(Node));
temp->next = temp1;
printf("What is the value for this entry?\n");
scanf("%d",&x);
temp1->data = x;
temp1->next = NULL;
}
void PrintList(){
Node* temp;
}
int main(void){
}
When I compile this code I get the compiler error:
pointertest.c: In function ‘AddEntry’:
pointertest.c:16:8: warning: assignment from incompatible pointer type [enabled by default]
temp = temp->next;
^
pointertest.c:19:13: warning: assignment from incompatible pointer type [enabled by default]
temp->next = temp1;
I am not understanding why that is. I’ve seen this done in my textbook and elsewhere. I thought it was assigning the pointer temp to address saved in temp next.
Thanks for your help