void del (node* list) {
int a;
printf("Enter no. to be deleted");
scanf("%d", &a);
node* p;
node* prev;
p = list;
while (p != NULL) {
if (p -> n == a) {
if (p == list) {
list = p -> next;
free (p);
return;
}
else {
prev -> next = p -> next;
free (p);
return;
}
}
else {
prev = p;
p = p -> next;
}
}
}
此代码删除除第一个节点之外的每个节点。当我尝试删除第一个节点时,它会给出随机数作为输出。可能是什么原因?