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?

  1. register c keyword: use name function.

  2. you have parantheses around callback parameter. should be:

    void funcname(void (*callback) (void)) 

Comments

Popular posts from this blog

Delphi Wmi Query on a Remote Machine -