C中的这个过程应该根据它的数据删除链表的一个元素,但每次调用它时它都会被卡住.我可以确认问题不在于声明列表的类型或相关的东西.
void supprime(list *head, int data2) {//failed
//data2 refers to the value we are looking for
list p= *head, k;
if (*head== NULL)
printf("the list is empty");
else {
while ((p->data!= data2) && (!p)) {
k= p;
p= p->next;
}
if (p->data == data2) {
k->next= p->next;
free(p);
}
else
printf("This data is not available\n");
}
}
Run Code Online (Sandbox Code Playgroud)
如果有人想要整个源代码,只是为了确保一切正常.