I want to pass to a function a pointer that can point to one of several functions.
What is the syntax for this?
void func_a(char c){
//
}
void func_b(char c){
//
}
void receiver(void (*function_pointer)()
{
// do stuff with the pointer to the function, e.g. call it:
function_pointer('a');
function_pointer('b');
function_pointer('c');
}
void main(){
receiver(&func_a); // calls func_a with 'a', then 'b', then 'c'
receiver(&func_b); // calls func_b with 'a', then 'b', then 'c'
}
Will the above work as expected? I assume a function pointer can only be used for functions with the same signature?
while( processor) { processor.exec(); processor = processor.next );