144Fermer146
hibouLe 06/08/2008 à 19:53
De toute facon, pour les closures, on s'en fou que la fonction soit locale ou pas, l'important c'est de pouvoir référencer une fonction via une variable locale. Donc il suffit de faire:
#include <stdbool.h> 
#include <stdlib.h> 
#include <stdio.h> 

int low;
int high;

int f(int x) {
 return (x>low && x<high);
}

int main (int argc, const char *argv[]) 
{ 
 
  low = atoi (argv[1]); 
  high = atoi (argv[2]); 
 
  int (*ptrFunc)(int) = &f;
 
  int x = 3; 
 
  printf ("collision = %d\n", (*ptrFunc)(x)); 
 return 0; 
}