L
larkmore
Ok, I have some functions:
void foo1(void){
//do some stuff
}
void foo2(void){
//do some stuff
}
void foo3(void){
//do some stuff
}
void foo4(void){
//do some stuff
}
And I have an array of what I _hope_ are pointers to functions (if they
aren't, I want them to be):
void *fct_ptrs[4] = {&foo1, &foo2, &foo3, &foo4};
My question is, what would the syntax be for my program to call the
function pointed to by an element in the array (e.g. I want to execute
fct_ptr[2])? Simple and easy I'm sure, but I am having a world of hurt
trying to decipher all the tutorials on function pointers I've come
across. The concept is easy. The syntax, not so clear... Thanks in
advance for any help!
-Will
void foo1(void){
//do some stuff
}
void foo2(void){
//do some stuff
}
void foo3(void){
//do some stuff
}
void foo4(void){
//do some stuff
}
And I have an array of what I _hope_ are pointers to functions (if they
aren't, I want them to be):
void *fct_ptrs[4] = {&foo1, &foo2, &foo3, &foo4};
My question is, what would the syntax be for my program to call the
function pointed to by an element in the array (e.g. I want to execute
fct_ptr[2])? Simple and easy I'm sure, but I am having a world of hurt
trying to decipher all the tutorials on function pointers I've come
across. The concept is easy. The syntax, not so clear... Thanks in
advance for any help!
-Will