在file1.h將函數作爲具有不同長度參數的指針傳遞給另一個函數?
// find the root of a function of one variable
double rootfind(double (*fp)(double), double start, double end);
在file2.h
// a function of multiple variables
double myfun(double a, double b);
double test();
在file2.c中
double myfun(double a, double b)
{
return (a+3.0)*(a-1.0)*(a-1.0)*b;
}
double test()
{
double b, start, end;
start = -4.0;
end = 4.0/3.0;
b = 2.0;
// How do I use the rootfinding function to find the root of myfun
// where b is set as a constant in this function?
// How do i find the root of myfun(x,2.0)?
}
我想保持rootfind功能一般在沒有額外的參數傳遞。我也不想使用gcc擴展來嵌套函數。
謝謝。我現在知道它叫什麼,所以我可以搜索它。你能解釋一下你對頂級靜態函數的含義嗎? – user1801359 2014-12-04 21:51:59