我正在使用链接列表并尝试在 where'th 节点之后插入一个带有数据 d 的新节点。出于某种原因,我得到了不正确的结果。这是我的代码:
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;
}