Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何用C语言编程删除双链表中的节点?我做了,但它返回分段错误。我不知道';我不知道哪一部分错了_C_Linked List_Doubly Linked List - Fatal编程技术网

如何用C语言编程删除双链表中的节点?我做了,但它返回分段错误。我不知道';我不知道哪一部分错了

如何用C语言编程删除双链表中的节点?我做了,但它返回分段错误。我不知道';我不知道哪一部分错了,c,linked-list,doubly-linked-list,C,Linked List,Doubly Linked List,这部分是双链表的结构代码 struct someEvent { int shouldRemove; struct someEvent *prev; struct someEvent *next; } * someEvent; struct someEvent *someEventQueue = NULL; struct someEvent **curr = &someEventQueue; if ((*curr) == NULL)

这部分是双链表的结构代码

struct someEvent
{
    int shouldRemove;
    struct someEvent *prev;
    struct someEvent *next;
} * someEvent;

struct someEvent *someEventQueue = NULL;
struct someEvent **curr = &someEventQueue; 
            if ((*curr) == NULL)
            {
                someEventQueue = &someEvent[0];
                someEventQueue->next = NULL;
                someEventQueue->prev = NULL;
            }
            else
            {

                while ((*curr)->next != NULL)
                {
                    curr = &(*curr)->next;
                }
                struct someEvent *tmp = (struct someEvent *)malloc(sizeof(struct someEvent));
                tmp = &someEvent[0];
                tmp->next = NULL;
                (*curr)->next = tmp;
                tmp->prev = (*curr);
            }
此部件正在将节点插入到双链接列表中

struct someEvent
{
    int shouldRemove;
    struct someEvent *prev;
    struct someEvent *next;
} * someEvent;

struct someEvent *someEventQueue = NULL;
struct someEvent **curr = &someEventQueue; 
            if ((*curr) == NULL)
            {
                someEventQueue = &someEvent[0];
                someEventQueue->next = NULL;
                someEventQueue->prev = NULL;
            }
            else
            {

                while ((*curr)->next != NULL)
                {
                    curr = &(*curr)->next;
                }
                struct someEvent *tmp = (struct someEvent *)malloc(sizeof(struct someEvent));
                tmp = &someEvent[0];
                tmp->next = NULL;
                (*curr)->next = tmp;
                tmp->prev = (*curr);
            }

此部分正在删除节点。在执行此操作之前,我检查了所有必须删除并使用shouldRemove标记的节点。如果shouldRemove为1,则应删除此节点。我认为这没有问题,但当我调试这段代码时,它在
中返回分段错误,而((*curr5)!=NULL)
(这段代码是删除节点部分的第四行)。我确实努力解决了这个问题,但我想我解决不了这个问题。。请给我一些建议。

阅读调试代码的提示。我很难理解这行代码在什么范围内存在。struct someEvent*someEventQueue=NULL@Gliad
struct someEvent*someEventQueue=NULL这一行是glabal方差。插入零件和删除零件代码是主要功能。请阅读,它使生活变得更加轻松。