This article is a follow up to: Introduction to using function pointers in C (or C++)
There’s a trick make life a bit easier when dealing with function pointers. We can typedef the function. In the previous article we used a feedback function. Let’s take it from there.
We prototyped our feedback function like this:
int (*feedback_fun)(char *str) ;
Instead we can create a new type of function like the above by using typedef like this:
typedef int (*feedback_ptr)(char *str);
Doing this we can make the function declarations look nicer. We can declare a variable holding a pointer to the feedback functions like this:
feedback_ptr feedback_fun ;
Nice isn’t it? But we haven’t won that much. We have to wait until we dive into plugins until we see the benefits if this.