Hi !
I'm using DevCpp in games development and I'm having a problem about =
passing function address as a parameter.
Example:
void show_message() {
printf("Message\n");
}
void call_function(void *func) {
// I receive the pointer to de function, but I can't execute it, =
like this:
func();
}
int main() {
call_function((void*)show_message);
getch();
}
In order to execute the function passed as parameter, I have this =
option:
void show_message() {
printf("Message\n");
}
void call_function(void func()) {
// This works fine, but I can't store the address of func() to =
execute it later.
func();
}
int main() {
call_function(show_message);
getch();
}
I've tried some typecasts, but the compiler doesn't accept.
Does anyone here have a suggestion?
Thanks!
Odilon J. Bedin |