首页 > 数据结构单链表插入问题。

数据结构单链表插入问题。

void Insert(ElementType X, List L, Position P)
{

Position TmpCell;

TmpCell =( struct Node*) malloc(sizeof(struct Node));
if (TmpCell == NULL)
    printf("Out of space.\n");

TmpCell->Element = X;
TmpCell->Next = P->Next;
P->Next = TmpCell;

}
这是插入功能的代码,调试的时候的信息是这样的。

这个代码道理我懂,但是为什么会出错。
谢谢。

谢谢大家。这个问题已经解决。


Position与Node混合着用,明显错了,全部改成Node,或者把错误混合使用的地方改过来


要定义的指针不是tmpCell 而是next 吧

【热门文章】
【热门文章】