0

I would like to know how i can pass a pointer to a function to another function as a parameter, only the function that i wish to pass has multiple parameters. For example, my main function:

void main_func(float **D, float **w , int n, Pointer_to_func)

The function that i want to pass:

float func(int x_1, int y_1, int x_2, int y_2 ,int q)

Thanks.

1
  • Hint: use typedefs to stop the syntax getting too hairy. Commented Jan 15, 2013 at 18:32

2 Answers 2

1

Or without a typedef (just for completeness, you generally do want the typedef):

void main_func(float **D, float **w , int n, float (*callback)(int, int, int, int, int));
Sign up to request clarification or add additional context in comments.

1 Comment

woops..Your answers were alike..so i tagged it by mistake.
1
typedef float (*func_t)(int x_1, int y_1, int x_2, int y_2 ,int q);
void main_func(float **D, float **w , int n, func_t callback)

1 Comment

Thanks. Learned something. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.