Voilà un exemple d'utilisation de pointeur de fonction :
#include <stdio.h>
// --- Déclaration du nouveau type "fct" = pointeur
// --- sur des fonctions de type "void xxx(const char*)"
typedef void(*fct)(const char*);
void fonction1(const char* texte)
{
printf("%s de fonction1\n",texte);
}
void fonction2(const char* texte)
{
printf("%s de fonction2\n",texte);
}
int main(void)
{
fonction1("appel direct");
fct p = fonction1;
p("appel indirect");
fonction2("appel direct");
p = fonction2;
p("appel indirect");
return 0;
}
Ce qui donne :
appel direct de fonction1
appel indirect de fonction1
appel direct de fonction2
appel indirect de fonction2
Dans votre cas :
typedef int(*task1)();
...
task1 adresse = nom_de_la_fonction;
Jean-François