Recentemente stavo leggendo un codice, e ha scoperto che un puntatore a funzione è scritta come:Scrivi puntatore a funzione in C
int (*fn_pointer (this_args))(this_args)
Io di solito incontrare un puntatore a funzione come questa:
return_type (*fn_pointer) (arguments);
Simile cosa è discusso here:
// this is a function called functionFactory which receives parameter n
// and returns a pointer to another function which receives two ints
// and it returns another int
int (*functionFactory(int n))(int, int) {
printf("Got parameter %d", n);
int (*functionPtr)(int,int) = &addInt;
return functionPtr;
}
qualcuno può dirmi qual è la differenza e come doe s questo lavoro?
puoi inserire il codice esatto? un campione compilabile? –
Questo potrebbe aiutare http: // StackOverflow.it/questions/840501/how-do-function-pointers-in-c-work? rq = 1 –
@ iharob: il mio codice è più lungo. Ho appena aggiornato. –