阅读背景:

当尝试在第一个元素之前插入节点时,在c中单个链表不起作用。

来源:互联网 

Given below singly linked list implementation in C is working fine until I use insertBefore() function below. In insertBefore() when i try to insert node before first element strange thing is happening. I tried printing list from inside insertBefore() which printed the list properly. But there seems some thing wrong when I try to return first. Because after returning in main when i try to print the same list its going in infinite loop. Point is that after returning in main when i tried printing value first.next->data its showing same value as that of first.data. This code was working for all other cases like insertAfter() and even inserBefore() when i tried inserting node at any other positions except before first node.Given below singly linked list implementation i




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: