For example:
void KeyFuncForA(char *OutputString) { printf("A: %s\n", OutputString); }
If we can use variable pointers to access memory to get the variables' value, we can also use function pointers to access memory to do a function call. And there are three important things you should know.
- The function return type.
- The parameter type.
- The number of parameter.
int TestFunc (unsigned char *ucPtr, char *String); // Prototype of function "TestFunc".
Now, we declare a function pointer called "FuncPtr" to point the function "Test Func":
int (*FuncPtr)(unsigned char*, char *); // Function pointer declaration.
After that, we can use the function pointer "FuncPtr" to point the function we want to use it, and this is how we can do:
FuncPtr = TestFunc; // Make "FuncPtr" point to function "TestFunc". FuncPtr(0xFF, "Hello!"); // Make a function call.To be continue...
沒有留言:
張貼留言