Passing a function as an argument

Hello,

I would like to pass the function "wifi_init()" (that is in a header file) as an argument from Check(wifi_init());
Could someone please assist me with the correct syntax. That is what I have

//initializing functions
void init();
void Check(void(*)());

void Check(void(*callback)())
{
Status = *callback;
}

void init()
{
Check(wifi_init());
}

wifi_init() is defined in another header file as void wifi_init(void);
Calling wifi_init(); in set up or loop works fine but not sure how to pass it..
Thanks!

Please use Code Tags!!

void Check(void(*callback)())
{
  Status = *callback;
}

How do you expect this to work if 'callback' is defined as a pointer to a function that returns no value?

If it did return a value, the proper syntax would be:

void Check(int (*callback)())
{
  Status = callback();
}

But, 'Status' is not defined in your code.

Thank you for your feedback and I do apologize for not using tagged code.
I fixed the error by passing the function as int and not including the * or ();
Thank you! :slight_smile: