나는 연결된 목록을 사용하고 where 노드 아래에 데이터 d가있는 새 노드를 삽입하려고 시도하고 있습니다. 어떤 이유로 나는 잘못된 결과를 얻고 있습니다. 여기 내 코드입니다 :n 번째 요소 뒤에 연결된 목록에 삽입
void insertAfter(int d, int where)
{
struct list * marker = head;
struct list * new;
while(marker -> data != where)
marker = marker -> next;
new = (struct list*)malloc(sizeof(struct list));
new -> next = marker -> next;
marker -> next = new;
new -> data = d;
}
'marker -> data! = where'는 n 번째를 의미하지 않습니다. – BLUEPIXY