I am trying to create a function pointer that takes in a pointer to double as an argument. What is the proper syntax to write in main?
This is what I have but it keeps spitting out errors.
void (*ptr)(double, double, (*double), (*double) );
It is the same way you would declare a double * parameter in a function's parameter list:
void (* ptr) (double, double, double *, double *);
Can be assigned to a function like:
void something (double w, double x, double *py, double *pz) {
}
This is true in the general case, no matter how complicated it gets. For example, a pointer to a function that takes an int and another function pointer (which points to a function that takes a double and a void * and returns a char*) as a parameter:
void (* ptr) (int, char * (*) (double, void *));
Then:
char * g (double w, void *) {
...
}
void f (int x, char * (* y) (double, void *)) {
...
}
// usage, elsewhere:
ptr = &f;
ptr(0, &g);
typedef types to something syntactically simpler. Then I can clearly see what's going on, and substitute the original types back in. For example, typedef double * double_ptr makes void (* ptr) (double, double, double_ptr, double_ptr) clear, then substituting double * back in shows you the correct syntax.