Funktionsaufruf dynamisch per adresse
-
Hi.
Sorry für die blöde Frage, dürfte schon 1000x beantwortet worden sein, aber entweder sind mir nicht die richtigen Suchbegriffe eingefallen, oder ich habs einfach nicht gefundenAuf jeden Fall würde ich gerne wissen wie ich eine Funktion anhand Ihrer Addresse aufrufe.
folgendes habe ich ohne Erfolg probiert:
typedef void (PROCNAME)(int, int);
danke schonmal im Voraus
-
Hallo
hier ist ein Tutorial zum Thema Funktionspointer
http://www.antivoid.za.net/index.php?page=tut02bis bald
akari
-
Meinst du einen Zeiger auf eine Funktion?
Dann so:
double add(double val1, double val2); // Hier die Funktion definieren... double (*funcPtr)(double, double) = add; // Zeiger auf die Funktion add(). (Prototyp von add muss bekannt sein)
Caipi
-
Das Tutorial zum 1.April, hm?
http://www.antivoid.za.net/index.php?page=tut02 schrieb:
Defining a function pointer
Look at a declaration of a normal function prototype:
int MyFunction(int Value1, char Value2);
We want to turn MyFunction into a pointer, and not an actual declaration. So like in a normal pointer, for example a pointer to int, we add an asterisk before the variable name. We then get this:
int *MyFunctionPointer(int Value1, char Value2);
And thats it! It makes sense; we have a set of brackets after MyFunction, which shows a list of parameters. But we dont want to have names for these parameters. So we will drop those. I also prefer to put brackets around the "*MyFunction" part because it makes it syntactically clearer that it is a function pointer. This will be be the syntax I use throughout this tutorial. Here is our example again, reformatted:
int (*MyFunctionPointer)(int, char);
Alternative Seite: www.function-pointer.org
-
@Tutorial: *LOL* ... *ROFL* Genial!