算法设计手册,第3章,链表代码片段混淆

log*_*ity 5 c algorithm pointers function-pointers

我正在阅读算法设计手册,在第 3 章中,出现了以下代码片段。它与从链表中删除项目有关。这个问题与数据结构无关,而仅与我认为声明了两个变量的一行代码有关。为简洁起见,我删除了代码中不相关的部分。

list *search_list(list *l, item_type x) {
  // This function just searches the list x
}

list *predecessor_list(list *l, item_type x) {
  // This function simply returns the predecessor of x or NULL
}

delete_list(list **l, item_type x) {
  list *p;     /* item pointer */
  list *pred;  /* predecessor pointer */

  list *search_list(), *predecessor_list(); // What are these declarations?

  p = search_list(*l,x);

  // Code to delete the node if found is here    
}
Run Code Online (Sandbox Code Playgroud)

我的问题是在delete_list function,具体而言,线路list *search_list(), *predecessor_list();。那条线上发生了什么?我猜它是一个指向函数的指针,但我的理解是你应该用适当的参数声明函数指针。另外,假设我是正确的,为什么甚至需要这些行?

ffh*_*dad 4

有问题的线路,

list *search_list(), *predecessor_list();
Run Code Online (Sandbox Code Playgroud)

通知编译器 an identifierfor afunction存在以及它的返回类型是什么。在这种情况下,不需要函数所需的参数的数量和类型。

我同意这有点奇怪而且不太直观,但是 C 语言支持许多这样的特性。

Dabo 对您的问题的评论中提供的链接更详细:为什么空声明适用于带 int 参数的定义,但不适用于 float 参数?