我怎样才能传递以下论点,它是什么样的?

How can I pass the following argument and what kind is it?

我对C比较陌生,找到了的代码。你如何传递函数的参数 double (*f)(double) 以及指针如何在其中工作?

函数如下:

double derivative(double (*f)(double), double x0, int order)

我猜你首先需要这样的东西:

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

double f(double x){
    return pow(x,2);
} 

int main(){
    double x = 2;
    int order = 2;
    derivative(f(x), x , 2);
}

我试过了,但没用。谢谢您的帮助。

double (*f)(double) 是一个函数指针。这意味着您需要传递一个指向(或只是名称)函数的指针。在您的尝试中,您正在调用函数,然后传递 return 值,这是不正确的。

正确的方法是:

derivative(f, x, 2);