从链表中删除特定数字(递归)

delete Certain number from linked list (recursive)

大家好,我正在尝试创建一个删除特定号码的功能 来自链接列表中具有此编号的所有单元格,但我的删除功能仅删除他到达末尾的第一个单元格,然后返回到主单元格 这是我的代码:

struct num* deleteCell(struct num* point, int numdelete)
{
    struct num* tempdelete = point;
    if (point == NULL)  // found the tail and dont found any match to delete
    {
        printf("not found\n");
        return NULL;
    }
    else if (point->number == numdelete)// found one to delete
    { 
        tempdelete = point->pNext;
        free(point);
    }
    else// Just keep going 
    { 
        point->pNext = deleteCell(point->pNext, numdelete);
    }
    return tempdelete;
}

(point是指向第一个单元格的指针,numdelete是我要删除的数字) 感谢帮助!!!!

阿龙

struct num* deleteCell(struct num* point, int numdelete) {
  if (point == NULL) {
     return NULL;
  }

  if (point->number == numdelete) { 
    num* tempdelete = point->pNext;
    free(point);
    return deleteCell(tempdelete, numdelete);
  }

  point->pNext = deleteCell(point->pNext, numdelete);
  return point;
}