int main() {

Node head = (Node)malloc(sizeof(struct node1));


for (int i = 1; i <= 5; i++) {

insert(head, i);

}


Node curr = head->next;

while (1) {

printf("%i", curr->num);

curr = curr->next;

}


return 0;

}


void insert(Node head, int data) {

Node list = (Node)malloc(sizeof(struct node1));

if (head == NULL) {

list->num = data;

list->next = list;

head = list;

}

else {

list->num = data;

list->next = head->next;

head->next = list;

}

}


이거 돌려보면 무한루프 안걸리고 curr 얘가 쓰레기값이라 에러뜨는데 왜그런거임?


원형이라서 무한루프 돌아야하는거 아님???


분명 끝이랑 처음이랑 이었는데 왜 쓰레기값이 뜨는거야....