Implementing callback functions in C -
i newbie c. trying implement callback function using function pointers.
i getting error
:test_callback.c:10: error: expected identifier or ‘(’ before ‘void’
when try compile following program:
#include<stdio.h> void (*callback) (void); void callback_proc () { printf ("inside callback function\n"); } void register ((void (*callback) (void))) { printf ("inside registration \n"); callback (); /* calling initial callback function pointer */ } int main () { callback = callback_proc;/* assigning function function pointer */ register (callback);/* passing function pointer */ return 0; }
what error?can help?
register
c keyword: use name function.you have parantheses around callback parameter. should be:
void funcname(void (*callback) (void))
Comments
Post a Comment