Let's say I have a function del
that I want to call as argument of a function use_del
in another function my_funct
, like this :
void del(void *d);
void use_del(char *str, void (*del)(void *));
void my_funct(void)
{
// code
char *str = "thing"
use_del(str, (*del));
// code
}
I sometime have an error message saying I should do
use_del(str, (*de)(str));
but it sounds counter intuitive to me, since I'm supposed to call a function, not pass an argument to it.
Is the big block of code the correct use of a function pointer used as an argument ? I couldn't find resources on the subject beyond genericity, and I still struggle to make tests on specific parts of a code.