title: Function pointers and callbacks in C
body: <p>I have started to review callbacks. I found this link on SO: 
  <a href="https://stackoverflow.com/questions/142789/what-is-a-callback-in-c-and-how-are-they-implemented">What is a &quot;callback&quot; in C and how are they implemented?</a>  It has a good example of callback which is very similar to what we use at work. However, I have tried to get it to work, but I have many errors.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  /* Is the actual function pointer? */
  typedef void (*event_cb_t)(const struct event *evt, void *user_data);
  
  struct event_cb
  {
      event_cb_t cb;
      void *data;
  };
  
  int event_cb_register(event_ct_t cb, void *user_data);
  
  static void my_event_cb(const struct event *evt, void *data)
  {
      /* do some stuff */
  }
  
  int main(void)
  {
      event_cb_register(my_event_cb, &amp;my_custom_data);
  
      struct event_cb *callback;
  
      callback-&gt;cb(event, callback-&gt;data);
  
      return 0;
  }
  </code></pre>
  
  <p>I know that callbacks use function pointers to store an address of a function. But there are a few things that I find I don't understand:</p>
  
  <ul>
  <li>What is meant by "registering the callback" and "event dispatcher"?</li>
  </ul>