우리는 수행 할 때 insertLast (INT 항목) 기능, 우리가 할 다음 단계 :삽입 요소 링크 된 목록에서
struct node *temp;
struct node *newItem;
newItem = (struct node*)malloc(sizeof(struct node));
temp = head;
while(temp->next != NULL){
temp = temp->next;
}
temp->next = newItem;
newItem->next = NULL;
하지만 우리가 할 경우 :
struct node *temp;
struct node *newItem;
newItem = (struct node*)malloc(sizeof(struct node));
temp = head;
while(temp != NULL){
temp = temp->next;
}
temp = newItem;
newItem->next = NULL;
우리 오류가 발생하는 이유는 무엇입니까?